【发布时间】:2013-11-12 06:29:45
【问题描述】:
#include <iostream>
#include <cmath>
using namespace std;
double T;
double V;
double WC(double T, double V);
void index(double WC(double T, double V));
int main(void)
{
cout<<"Please enter your T followed by your V"<<endl;
cin>>T>>V;
cout<<index;
}
double WC(double, double)
{
if(V>4.8)
return 13.12+0.6215*T-11.37*pow(V,0.16)+0.3965*T*pow(V,0.16);
else
return T;
}
void index(double WC(double,double))
{
if (WC(T,V)<=0&&WC(T,V)>=-25)
{
cout<<"Discomfort";
}
if (WC(T,V)<-25&&WC(T,V)>=-45)
{
cout<<"Risk of skin freezing (frostbite)";
}
if (WC(T,V)<-45&&WC(T,V)>=-60)
{
cout<<"Exposed skin may freeze within minutes";
}
if (WC(T,V)<-60)
{
cout<<"Exposed skin may freeze in under 2 minutes";
}
}
我不明白为什么会输出像“010F11B8”这样的随机乱码,它只是应该根据输入的温度和风速打印一些东西。
【问题讨论】:
-
你没有调用你的
index函数并打印出index函数的地址 -
假设您使用的是 UNIX/Linux,这可能会有所帮助:sourceware.org/gdb/current/onlinedocs/gdb
-
详细说明
Ed S的观点:T是什么?V是什么?WC是什么?您只使用一个提示并同时输入而不是提示输入提示输入?等等……
标签: c++ function parameters parameter-passing