⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windchill.cpp

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 CPP
字号:
#include <iostream>#include <iomanip>       // for setw#include <cmath>         // for sqrtusing namespace std;// Owen Astrachan// nested loops to print wind-chill chart//// idea: Programming with Class by Kamin and Reingold, McGraw-Hill// formula for wind-chill from// UMAP Module 658, COMAP, Inc., Lexington, MA 1984, Bosch and Cobbdouble WindChill(double temperature, double windSpeed);int main(){    const int WIDTH = 5;    const int MIN_TEMP = -40;    const int MAX_TEMP = 50;    const string LABEL = "deg. F: ";    int temp,wind;    // print column headings        cout << LABEL;    for(temp = MAX_TEMP; temp >= MIN_TEMP; temp -=10)    {   cout << setw(WIDTH) << temp;    }    cout << endl << endl;    // print table of wind chill temperatures        for(wind = 0; wind <= MAX_TEMP; wind += 5) // row heading    {   cout  << wind << " mph:\t";                for (temp = MAX_TEMP; temp >= MIN_TEMP; temp -= 10)  // print the row        {   cout << setw(WIDTH) << int(WindChill(temp,wind));        }        cout << endl;    }    return 0;}double WindChill(double temperature, double windSpeed)// precondition: temperature in degrees Fahrenheit// postcondition: returns wind-chill index/comparable temperature{    if (windSpeed <= 4)          // low wind, temperature unaltered    {   return temperature;    }    else if (windSpeed <= 45)    // high wind    {   return           91.4 - (10.45 + 6.69*sqrt(windSpeed) - 0.447 * windSpeed) *           (91.4 - temperature)/22.0;    }    else    {   return (1.6 * temperature - 55.0);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -