5.8华氏温度变摄氏温度和绝对温度
#include <stdio.h>
void Temperatures(double);
int main(void)
{
double Fahrenheit;
// scanf("%lf",&Fahrenheit);
while(scanf("%lf",&Fahrenheit)==1) //scanf的返回值代表成功输入的变量的数目,非数字不会被成功输入
{
Temperatures(Fahrenheit);
scanf("%lf",&Fahrenheit);
}
printf("error input\n");
return 0;
}
void Temperatures(double num)
{
double Celsius,Kelvin;
const double a=1.8;
const double b=32.0;
const double c=273.16;
Celsius=a*num+b;
Kelvin=Celsius+c;
printf("%lf Fahrenheit is %.2lf Celsius and %.2lf Kelvin\n",num,Celsius,Kelvin);
}
本文介绍了一个简单的C语言程序,该程序可以将华氏温度转换为摄氏温度和绝对温度(开尔文)。通过使用基本的数学公式和C语言的标准输入输出函数,程序实现了连续读取用户输入的华氏温度,并输出对应的摄氏温度和开尔文温度。
中文版 第五章 编程练习&spm=1001.2101.3001.5002&articleId=7273131&d=1&t=3&u=cd315051bfbe411c889c5bb84c9a219a)

被折叠的 条评论
为什么被折叠?



