华氏温度与摄氏温度对照表

华氏温度与摄氏温度对照表

C语言代码块

#include<stdio.h>
      2 
      3 
      4 main()
      5 {
      6         int fahr,celsius;
      7         int lower,upper,step;
      8         lower=0;  //温度表的下限
      9         upper=300;  //温度表的上限
     10         step=10;  //步长
     11         fahr=lower;
     12         while(fahr<=upper)
     13         {
     14                 celsius=5*(fahr-32)/9;  /*计算指定华氏度转换成摄氏度,必须先乘5再除以9,因为整数除法进行舍位。*/
     15                 printf("%d\t%d\n",fahr,celsius);
     16                 fahr=fahr+step;
     17         }
     18 }

结果如下

[root@localhost boke]# ./a.out
0       -17
10      -12
20      -6
30      -1
40      4
50      10
60      15
70      21
80      26
90      32
100     37
110     43
120     48
130     54
140     60
150     65
160     71
170     76
180     82
190     87
200     93
210     98
220     104
230     110
240     115
250     121
260     126
270     132
280     137
290     143
300     148

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值