跳到正文

题解

B2013 温度表达转化 题解

little_cindy约 1 分钟
原文
文章信息与版本

文章信息

发布
2021年7月3日
收录
2026年11月29日
更新
2026年11月29日
篇幅
约 1 分钟
获赞
33
题目
B2013

版本

  1. v1当前

利用公式 C=5×(F−32)/9C=5 \times (F - 32)/9 我们可以写出这样的代码:

C++
#include<bits/stdc++.h>
using namespace std;
int main(){
	double F,C;
	cin>>F;
	C=5*(F-32)/9;
	cout<<C;
	return 0;
}

发现小数部分不对。再根据要求精确到小数点后 5 位。经过修改,就可以写出正解了。

C++
#include<bits/stdc++.h>
using namespace std;
int main(){
	double F,C;
	cin>>F;
	C=5*(F-32)/9;
	printf("%0.5f",C);
	return 0;
}