c语言程序设计答案

输入一个华氏温度,要求输出摄氏温度.公式为c=5/9*(F-32)输出要有文字说明,去两为小数

1.// 华氏温度与摄氏温度对照表

#include<stdio.h>
#include<stdlib.h>

int main()
{
float fahr = 0,cels = 0;
int low = 0,max = 300,step = 20;

printf ("\t=========本程序输出华氏和摄氏的温度对照!==========\n\t2006-12-30\n");

fahr = low;
printf ("\n\n华氏温度: 摄氏温度:\n-------- --------\n");
for (;fahr <= max;)
{
cels = 5.0 / 9.0 * (fahr - 12);
printf ("%.0f\t\t %6.2f\n",fahr,cels);
fahr += step;
}
system("pause");
return 0;
}
2.#include <stdio.h>

void main(void)
{
float c,F;
printf("请输入华氏温度:");
scanf("%f",F);

c=5/(9*(F-32));

printf("对应摄氏温度为%.2f",c); //取2位小数
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-10-20
#include<stdio.h>
main()
{ int F;
float c;
printf("please input a number:");
scanf("%d",&F);
c=5/9*(F-32);
printf("the tempereture is: ");
printf("c=%2f",c);
}
输入:华氏温度。
输出:摄氏温度。
讲解;先编译两个变量f,c,再读入华氏温度,通过公式计算,把值输出,
就是摄氏温度。
望采纳。
第2个回答  2008-10-13
#include "stdio.h"
void main()
{
float c,f;
printf("请输入一个华氏温度:\n");
scanf("%f",&f);
c=(5.0/9.0)*(f-32);/*注意5和9要用初开表示,否则5/9的值为0*/
printf("摄氏温度为:%5.2f\n",c);

}
第3个回答  2008-10-13
#include "stdio.h"
void main()
{
float F;
printf("请输入一个华氏温度,我们将给出其摄氏温度:\n");
scanf("%f",&F);

printf("摄氏温度为:%0.2f",(5.0/9.0*(F-32)));

}
第4个回答  2008-10-13
#include<stdio.h>
main()
{ int F;
float c;
printf("please input the tempereture:");
scanf("%d",&F);
c=5.0/9*(F-32); /*若是5/9,那么得到的结果是0;显然不是我们要的,所以将其中一个数据改成实型就可以了。*/
printf("the tempereture is: ");
printf("%.2f\n",c);
}