逻辑概述:
华氏温度用°F表示,摄氏度用°C表示。
换算公式是:C=5/9×(F-32)
代码示例:
#include <stdio.h>
int main()
{
float f,c;
printf("Please emter a temperature is Fahrenheit:");
//请输入华氏温度:
scanf("%f", &f);
c = 5.0 / 9.0 * (f-32);
printf("\nThis Fahrenheit temperature is %.1f°F\n", f);
//这个华氏温度是
printf("This centigrade temperature is %.1f°C\n", c);
//这个摄氏度是
return 0;
}
输入示例:
Please emter a temperature is Fahrenheit:64
输出示例:
Please emter a temperature is Fahrenheit:64
This Fahrenheit temperature is 64.0°F
This centigrade temperature is 17.8°C