描述
输入华氏温度f,计算并输出相应的摄氏温度c(保留2 位小数)。c = 5/9(f-32).
输入
输入一个实数x表示华氏温度
输出
输出对应的摄氏温度
输入样例 1
17.2
输出样例 1
The temprature is -8.22
这是一个计算华氏温度到摄氏温度的题目,题目已经给出了算式c = 5/9(f-32)所以只需要按照公式计算即可,注意5和9需要使用5.0和9.0以保证得到的为浮点数。
//1028
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
float x,f;
while(cin>>x)
{
f=(5.0/9.0)*(x-32.0);
printf("The temprature is %0.2f\n",f);
}
return 0;
}