#include <iostream>
#include <vector>
#include <time.h>
using namespace std;
enum TIME_TABLE_TYPE {
TT_LESSON,TT_SMALL_BREAK,TT_LONG_BREAK
};
struct tm add_time(struct tm time1, struct tm time2);
void print_time(struct tm timeinfo);
int main() {
struct tm lesson_start;
struct tm lesson_length;
struct tm small_break;
struct tm long_break;
// Init default values
lesson_start.tm_hour = 8;
lesson_start.tm_min = 45;
lesson_length.tm_hour = 0;
lesson_length.tm_min = 45;
small_break.tm_hour = 0;
small_break.tm_min = 30;
long_break.tm_hour = 0;
long_break.tm_min = 45;
// Init time_table
vector <int> time_table = {TT_LESSON,TT_SMALL_BREAK,TT_LESSON,TT_SMALL_BREAK,TT_LESSON,TT_SMALL_BREAK,TT_LESSON,
TT_LONG_BREAK,TT_LESSON};
struct tm timeinfo = lesson_start;
for(vector<int>::iterator i = time_table.begin(); i != time_table.end(); i++) {
if (*i == TT_LESSON) {
print_time(timeinfo);
timeinfo = add_time(timeinfo,lesson_length);
print_time(timeinfo);
} else if (*i == TT_SMALL_BREAK) {
timeinfo = add_time(timeinfo,small_break);
} else if (*i == TT_LONG_BREAK) {
timeinfo = add_time(timeinfo,long_break);
}
}
return 0;
}
void print_time(struct tm timeinfo) {
cout << timeinfo.tm_hour << " : " << timeinfo.tm_min << endl;
}
struct tm add_time(struct tm time1, struct tm time2) {
time1.tm_hour +=time2.tm_hour;
time1.tm_min += time2.tm_min;
if (time1.tm_min >= 60) {
time1.tm_hour = time1.tm_hour + 1;
time1.tm_min -= 60;
}
return time1;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8dGltZS5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKZW51bSBUSU1FX1RBQkxFX1RZUEUgewogICAgVFRfTEVTU09OLFRUX1NNQUxMX0JSRUFLLFRUX0xPTkdfQlJFQUsKfTsKCnN0cnVjdCB0bSBhZGRfdGltZShzdHJ1Y3QgdG0gdGltZTEsIHN0cnVjd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