时间转换
1 #include<stdio.h> 2 3 int main(void) 4 { 5 int bjt; 6 7 scanf_s("%d", &bjt); 8 9 int bjt_hour = bjt / 100; 10 int bjt_minute = bjt % 100; 11 12 int utc_hour = bjt_hour - 8; 13 if (utc_hour < 0) 14 { 15 utc_hour = utc_hour + 24; 16 } 17 18 if (utc_hour > 0) 19 { 20 printf("%d%02d", utc_hour, bjt_minute); 21 } 22 else 23 { 24 printf("%d", bjt_minute); 25 } 26 27 return 0; 28 }
参考这个博客,https://blog.csdn.net/sinat_41853451/article/details/83239277,写了第二版。
1 #include<stdio.h> 2 3 int main(void) 4 { 5 int bjt; 6 int utc; 7 8 scanf_s("%d", &bjt); 9 10 if (bjt < 800) 11 { 12 utc = bjt + 2400 - 800; 13 } 14 else 15 { 16 utc = bjt - 800; 17 } 18 19 printf("%d", utc); 20 21 return 0; 22 }