-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathD.cpp
More file actions
31 lines (21 loc) · 820 Bytes
/
D.cpp
File metadata and controls
31 lines (21 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
int main() {
int start_h, start_m, start_s;
int end_h, end_m, end_s;
std::cin >> start_h >> start_m >> start_s;
std::cin >> end_h >> end_m >> end_s;
int start_total_seconds = start_h * 3600 + start_m * 60 + start_s;
int end_total_seconds = end_h * 3600 + end_m * 60 + end_s;
int diff_seconds = end_total_seconds - start_total_seconds;
if (diff_seconds < 0) {
diff_seconds += 24 * 3600;
}
int duration_h = diff_seconds / 3600;
int duration_m = (diff_seconds % 3600) / 60;
int duration_s = diff_seconds % 60;
std::cout << "Продолжительность промежутка: "
<< duration_h << " ч "
<< duration_m << " мин "
<< duration_s << " сек" << std::endl;
return 0;
}