1 条题解
-
0
练11.1温度表达转化
解题思路
直接代入摄氏温度公式 5(F-32)/9,保留五位小数。
正确性说明
公式由题目给出,使用浮点运算保持小数精度。
易错点
不能先做整数 5/9;摄氏温度允许负数。
复杂度
本题输入规模固定,时间 O(1),额外空间 O(1)。
参考代码(C++11)
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); double f; cin >> f; cout << fixed << setprecision(5) << 5 * (f - 32) / 9 << "\n"; return 0; }
- 1