输出加1秒后的新时间.C 438 B

123456789101112131415161718192021222324252627
  1. #include <stdio.h>
  2. int main() {
  3. int hour, minute, second;
  4. scanf("%d:%d:%d", &hour, &minute, &second);
  5. second++;
  6. if (second >= 60) {
  7. second = 0;
  8. minute++;
  9. if (minute >= 60) {
  10. minute = 0;
  11. hour++;
  12. if (hour >= 24) {
  13. hour = 0;
  14. }
  15. }
  16. }
  17. printf("%02d:%02d:%02d\n", hour, minute, second);
  18. return 0;
  19. }