逻辑概述:

        华氏温度用°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

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐