利用公式 我们可以写出这样的代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
double F,C;
cin>>F;
C=5*(F-32)/9;
cout<<C;
return 0;
}发现小数部分不对。再根据要求精确到小数点后 5 位。经过修改,就可以写出正解了。
#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;
}