알고리즘/SW Expert Academy
[D3] 7732. 시간 개념
혬혬
2019. 10. 6. 11:12
728x90
#include <stdio.h>
int main() {
int test_case = 0;
scanf("%d", &test_case);
char buffer = 0;
scanf("%c", &buffer);
for (int q = 0; q < test_case; q++) {
int present_hours = 0;
int present_min = 0;
int present_second = 0;
int future_hours = 0;
int future_min = 0;
int future_second = 0;
int remain_hours = 0;
int remain_second = 0;
int remain_min = 0;
scanf("%d:%d:%d",&present_hours,&present_min,&present_second);
scanf("%d:%d:%d", &future_hours, &future_min, &future_second);
if (present_hours > future_hours||(present_hours==future_hours&&present_min>future_min)||(present_hours==future_hours&&present_min==future_min&&present_second>future_second)) {
future_hours += 24;
}
if (future_second < present_second) {
future_min--;
future_second += 60;
}
remain_second = future_second - present_second;
if (future_min < present_min) {
future_hours--;
future_min += 60;
}
remain_min = future_min - present_min;
remain_hours = future_hours - present_hours;
printf("#%d ", q+1);
if (remain_hours < 10)
printf("0%d:", remain_hours);
else
printf("%d:", remain_hours);
if(remain_min<10)
printf("0%d:", remain_min);
else
printf("%d:", remain_min);
if(remain_second<10)
printf("0%d", remain_second);
else
printf("%d", remain_second);
printf("\n");
}
return 0;
}
728x90