-1
我想打印索引表,就像我在這裏的索引表 但它沒有正確排列。我想我錯過了一個結局; 預先感謝您。他們不會讓我發佈這個問題沒有更多的上下文,所以我打字這看看這是否可能工作。我的索引表沒有排隊
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
cout << "Wind Chill Table" << endl; //Produces the table
cout << "Speed Temperature T " << endl; //Produces the table
cout << "MPH"; //Produces the table
for (int temp = 45; temp >= -10; temp -= 5) // Generate temp 45 to -10
{
cout << setw(5)<< temp ;
}
cout << endl;
for (int count = 0; count <= 62; count++) // generate the lines "------"
{
cout << "-" ;
}
cout << endl;
for(int speed = 5; speed <=50; speed+=5) // generate the speed 5 to 50
{
cout << setw(5)<< speed <<"|" << endl;
for (int temp = 45; temp >=-10; temp -= 5)
{
cout << setw(5)<<windchill(speed,temp);// calling the function windchill
}
cout << endl;
}
return 0;
}
int windchill(int s, int t)// function to calculate the wind chill
{
int windChillFactor = int(round(35.74 + 0.6215 *
t - 35.75 * pow(s, 0.15) +
0.4275 * t * pow(s, 0.16))); //Formula for wind chill
return windChillFactor;
}