温度表的逆运算
题目:下面的程序用公式 %C=(5/9)(°F-32)修改温度转换程序,要求以逆运算打印温度转换表,即从300到0
0 -17
20 -6
404
6015
8026
1037
12048
14060
16071
18082
20082
220104
240115
260126
280137
300148
不知道这个代码满不满足你的需求
代码如下:
#include <stdio.h>
int main()
{
float f={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
int i;
i=0;
int j;
j=0;
//华摄氏度从300开始
for(i=300;i>=0;i=i-20){
f=(5.0/9.0)*(i-32);
++j;
}
//因为要逆序输出,所以从0开始输出的就是300华氏度转为摄氏度的了
for(j=0;j<16;j++){
printf("摄氏度为%.2f\n",f);
}
return 0;
}
运行结果如下:
OK 希望有用吧
页:
[1]