-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnextminute.cpp
59 lines (46 loc) · 1.41 KB
/
nextminute.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "nextminute.h"
// Ïåðåãðóæåííûå ôóíêöèè, âîçâðàùàþùèå ñëåäóþùóþ ìèíóòó:
time nextMinute(time t) {
cout << "\tÂûçâàíà ôóíêöèÿ:\n";
cout << "\ttime nextMinute(time t)\n";
return nextMinute(t.hours, t.minutes, t.seconds);
}
// Òðè öåëî÷èñëåííûõ ïàðàìåòðà: ÷àñû, ìèíóòû, ñåêóíäû:
time nextMinute(int hours, int minutes, int seconds) {
cout << "\tÂûçâàíà ôóíêöèÿ:\n";
cout << "\ttime nextMinute(int hours, int minutes, int seconds)\n";
time result = nextMinute(hours, minutes);
result.seconds = seconds;
return result;
}
// Äâà öåëî÷èñëåííûõ ïàðàìåòðà: ÷àñû, ìèíóòû:
time nextMinute(int hours, int minutes) {
cout << "\tÂûçâàíà ôóíêöèÿ:\n";
cout << "\ttime nextMinute(int hours, int minutes)\n";
time result;
result.hours = minutes == 59 ? (hours + 1) % 24 : hours;
result.minutes = (minutes + 1) % 60;
result.seconds = 0;
return result;
}
// Ïåðåãðóæåííûå ôóíêöèè ïå÷àòè âðåìåíè:
void printTime(time t) {
printTime(t.hours, t.minutes, t.seconds);
}
// Òðè öåëî÷èñëåííûõ ïàðàìåòðà: ÷àñû, ìèíóòû, ñåêóíäû:
void printTime(int hours, int minutes, int seconds) {
printTime(hours, minutes);
cout << ":";
if (seconds < 10)
cout << "0";
cout << seconds;
}
// Äâà öåëî÷èñëåííûõ ïàðàìåòðà: ÷àñû, ìèíóòû:
void printTime(int hours, int minutes) {
if (hours < 10)
cout << "0";
cout << hours << ":";
if (minutes < 10)
cout << "0";
cout << minutes;
}