习题 3.3 输入一个华氏温度,要求输出摄氏温度。公式为C=5/9(F-32),输出要有文字说明,取两位小数。

阅读 197

2022-02-19

习题 3.3 输入一个华氏温度,要求输出摄氏温度。公式为C=5/9(F-32),输出要有文字说明,取两位小数。

代码:

#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;


int main()
{
	float f, c;

	cout << "输入一个华氏温度 :" << endl;
	cin >> f;

	c = ((f - 32) * 5) / 9;
	cout << setiosflags(ios::fixed) << setprecision(2);
	cout << "摄氏温度为:" <<c<< endl;

	return 0;
}

运行结果:

相关推荐

精彩评论(0)

0 0 举报