1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 14:36:19 +00:00
202401-programming-assignments/【实践课外】2.选择结构1/7-4 21选择-手表调整.c

34 lines
877 B
C

#include <stdio.h>
int main() {
int hh, mm, ss;
scanf("%d:%d:%d", &hh, &mm, &ss);
int time_seconds = hh * 3600 + mm * 60 + ss;
int news_seconds = 19 * 3600;
int divide_seconds = 7 * 3600;
if (time_seconds <= divide_seconds) {
time_seconds += 24 * 3600;
}
if (time_seconds > news_seconds) {
int diff_seconds = time_seconds - news_seconds;
int diff_hh = diff_seconds / 3600;
int diff_mm = diff_seconds % 3600 / 60;
int diff_ss = diff_seconds % 60;
printf("+%02d:%02d:%02d\n", diff_hh, diff_mm, diff_ss);
} else {
int diff_seconds = news_seconds - time_seconds;
int diff_hh = diff_seconds / 3600;
int diff_mm = diff_seconds % 3600 / 60;
int diff_ss = diff_seconds % 60;
printf("-%02d:%02d:%02d\n", diff_hh, diff_mm, diff_ss);
}
return 0;
}