W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
#include
using namespace std; // 将华氏度转换为摄氏度的函数 float toCelsius(float fahrenheit) { return (5.0 / 9.0) * (fahrenheit - 32.0); } int main() { // 设置华氏温度值 float f_value = 98.8; // 调用转换函数 float result = toCelsius(f_value); // 输出华氏温度值 cout << "华氏度: " << f_value << "\n"; // 输出转换结果 cout << "华氏度转摄氏度: " << result << "\n"; return 0; }