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


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 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM