输出华氏-摄氏温度转换表

https://pintia.cn/problem-sets/13/problems/408

 1 #include <stdio.h>
 2 int main(void)
 3 {
 4     int lower, upper;
 5     int fahr;
 6     double celsius;
 7 
 8     scanf("%d %d", &lower, &upper);
 9     if (lower <= upper && upper <= 100)
10     {
11         printf("fahr celsius\n");
12         for (fahr = lower; fahr <= upper; fahr += 2)
13         {
14             celsius = 5.0 * (fahr - 32) / 9;
15             printf("%d%6.1f\n", fahr, celsius); //%6.1f,6是显示宽度,不足6位,在左边添加空格
16         }
17     }
18     else
19     {
20         printf("Invalid\n");
21     }
22 
23     return 0;
24 }

 

posted @ 2020-02-02 21:07  jason2018  阅读(947)  评论(0编辑  收藏  举报