2015-04-03 18 views
0

The wind chill index combines the temperature and wind speed to tell us how cold the wind makes it "feel." The new wind chill index (often called the 「wind chill factor」) used by the US and Canadian weather services is determined by iterating a model of skin temperature under various wind speeds and temperatures. The results of this model may be approximated, to within one degree, from the following formula. windchill = round(35.74 + 0.6215 * T – 35.75 * S 0.16 + 0.4275 * T * S 0.16) Where T is the temperature in degrees Fahrenheit, and S is the wind speed in miles per hour. Write a program that will produce the following wind chill table. You must use a nested loop.以有組織的方式計算嵌套的for-loops

我在做什麼錯?

我回來錯誤背靠背。謝謝!

Wind Chill Table 
Speed Temperature T 
MPH 45 40 35 30 25 20 15 10 5 0 -5 -10 
----------------------------------------------------------- 
5 | 42 36 31 25 19 13 7 1 -5 -11 -16 -22 
10 | 40 34 27 21 15 9 3 -4 -10 -16 -22 -28 
15 | 38 32 25 19 13 6 0 -7 -13 -19 -26 -32 
20 | 37 30 24 17 11 4 -2 -9 -15 -22 -29 -35 
25 | 36 29 23 16 9 3 -4 -11 -17 -24 -31 -37 
30 | 35 28 22 15 8 1 -5 -12 -19 -26 -33 -39 
35 | 35 28 21 14 7 0 -7 -14 -21 -27 -34 -41 
40 | 34 27 20 13 6 -1 -8 -15 -22 -29 -36 -43 
45 | 33 26 19 12 5 -2 -9 -16 -23 -30 -37 -44 
50 | 33 26 19 12 4 -3 -10 -17 -24 -31 -38 -45 
----------------------------------------------------------- 
#include <iostream> 
#include <cmath> 
#include <iomanip> 

int main() 
{ 
int t; 
int s; 
    int windchill; 
    //cout << setw(5) << x; 

    //YOUR CODE: output the table heading (top 4 rows of table) with separate  cout stm$ 


//YOUR CODE: Two nested for-loops to generate speed S= 5, 10, ...,50 and 
// temperature T = 45, 40, ..., -10 
//in the innermost loop the windchill should be calculated and displayed 

for(t=50;t<=-10;t-5) 
{ 

windchill = round(35.74+0.6215*t-35.75*pow(s,0.16)+0.4275*t*pow(s,0.16)); 

cout << windchill; 
    for(s=0;s>=50;s+5) 
    { 
    cout << s; 


    } 

} 
return 0; 
} 
+1

你有哪些錯誤? – ForceBru 2015-04-03 16:52:41

+0

prog4.cpp:24:錯誤:'cout'未在此範圍內聲明 – 2015-04-03 16:58:18

回答

0

如果‘cout’ was not declared in this scope是唯一的錯誤,那麼您的修復程序就在這裏。

添加using namespace std;到您的文件的開頭(後包括)使用std::cout代替cout

+0

瘋了我,非常感謝! – 2015-04-03 17:57:12

+0

現在我收到0 – 2015-04-03 18:38:05

+0

@AaronNettles,究竟在哪裏? – ForceBru 2015-04-04 10:15:14