当前位置: 代码迷 >> 综合 >> 问题1028:华氏温度转换为摄氏温度
  详细解决方案

问题1028:华氏温度转换为摄氏温度

热度:38   发布时间:2024-01-28 18:29:00.0

华氏温度转换为摄氏温度

描述

 

输入华氏温度f,计算并输出相应的摄氏温度c(保留2 位小数)。c = 5/9(f-32).

输入

 

输入一个实数x表示华氏温度

输出

 

输出对应的摄氏温度

输入样例 1

17.2

输出样例 1

The temprature is -8.22
#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;
}

调用c的头文件控制保留2为小数