c primer plus(第五版)中文版 第五章 编程练习
2012-02-19 21:03
197 查看
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);
}
#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 Primer Plus (第五版) 第五章 编程练习 答案
- C++ Primer Plus 第五版中文版 第六章 编程练习6
- C primer plus(第五版)编程练习第五章
- C Primer Plus (第五版) 第五章 编程练习
- c++ primer plus(第6版)中文版 第五章编程练习答案
- C++.Primer.Plus第五版第五章编程练习答案
- C++ Primer Plus第五版 第五章 编程练习答案
- 记录——《C Primer Plus (第五版)》第十章编程练习第九题
- c++ primer plus(第6版)中文版 第十二章编程练习答案
- C Primer Plus (第六版)中文版 第十四章 编程练习答案
- c++.primer.plus第五版第六章编程练习答案
- c++.primer.plus第五版第七章编程练习答案
- C Primer Plus (第五版) 第六章 编程练习
- 记录——《C Primer Plus (第五版)》第八章编程练习第三题
- C++ primer plus(中文版) 第五章编程练习题
- C++ Primer Plus 第6版 中文版 第4章编程练习
- C++ PRIMER PLUS (第六版) 中文版 第七章编程练习答案
- 记录——《C Primer Plus (第五版)》第九章编程练习第八题
- C++ Primer Plus (第6版)编程练习 代码-----第五章
- c++ primer plus(第6版)中文版 第九章编程练习答案