Fahrenheit to Celsius
Enter a temperature in Fahrenheit and output a temperature in Celsius. The formula is:
c = 5 9 (F − 32). C=\frac{5}{9}\left( F-32 \right).c=95(F−32).
Enter a float F., Corresponding to the output temperature in Celsius and c 2 decimal places, note that the output end of line wrap.
enter
45.3
Output
7.39
/*
华氏温度转摄氏温度
*/
#include<iostream>
#include<iomanip> //I/O流控制头文件,用于格式化输出
using namespace std;
int main(void)
{
float f,c;
cin>>f;
c=5.0/9*(f-32);
cout<<fixed<<setprecision(2)<<c<<endl; //控制输出精度
return 0;
}