輸出華氏-攝氏溫度轉換表


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