0
点赞
收藏
分享

微信扫一扫

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

猫er聆听没落的旋律 2022-02-19 阅读 197
c语言c++

习题 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 条评论