#include <stdio.h>

int main() { int mode; double temp;

printf("请选择模式:\n");
printf("1. 华氏度(℉)转摄氏度(℃)\n");
printf("2. 摄氏度(℃)转华氏度(℉)\n");
scanf("%d", &mode);

if (mode == 1) {
    printf("请输入华氏度:\n");
    scanf("%lf", &temp);
    temp = (temp - 32) * 5 / 9;
    printf("转换后的摄氏度为:%.2lf℃\n", temp);
} else if (mode == 2) {
    printf("请输入摄氏度:\n");
    scanf("%lf", &temp);
    temp = temp * 9 / 5 + 32;
    printf("转换后的华氏度为:%.2lf℉\n", temp);
} else {
    printf("输入错误,请重新选择模式。\n");
}

return 0;

}

C语言温度转换程序:摄氏度与华氏度相互转换

原文地址: https://www.cveoy.top/t/topic/kEOQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录