#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'功能並打印出索引函數的地址 –
假設你在UNIX/Linux中,這可能會有幫助:http://sourceware.org/gdb/current/onlinedocs/gdb/ –
爲了詳細說明'Ed S'' s點:什麼是'T'?什麼是'V'?什麼是'WC'?您只使用一個提示並同時接受輸入而不是即時輸入提示輸入?等... – nhgrif