输入华氏度输出摄氏度和开尔文温度

来源:互联网 发布:电脑淘宝达人淘在哪里 编辑:程序博客网 时间:2024/06/03 03:00
#include<stdio.h>   
void Temperatures(double); 
const float K = 1.8; 
const float A = 32.0; 
const float B = 273.16;   
int main() 
{
 
double TEM;  
int a;   
printf("please input the degree Fahrenheit:");  
a = scanf("%lf",&TEM);  
while(a == 1)  
{
  
Temperatures(TEM);    
printf("please input the degree Fahrenheit(q to quit):");   
a = scanf("%lf",&TEM);  
}  
return 0;  
}  
void Temperatures(double TEM) 
{
 
double celsius,kelvin;  
celsius = (TEM-A) / K;  
kelvin = celsius + B;   
printf("Fahrenheit:%.2lf,  Celsius:%.2lf,  Kelvin:%.2lf\n",TEM,celsius,kelvin); 
0 0
原创粉丝点击