7月四日
完成了資料結構的第二個題目;老闆的作息表,這是我的原始碼
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
struct node{
string begin, end;
}times[100001];
bool cmp(const node& t1,const node& t2) {
return t1.begin < t2.begin;
}
int main()
{
int num;
cin >> num;
char c;
for (int i = 0; i < num; i++) {
cin >> times[i].begin >> c >> times[i].end;
}
sort(times, times + num, cmp);
if (times[0].begin != "00:00:00") {
if (num != 0) {
cout << "00:00:00" << " - " << times[0].begin << endl;
}
else {
cout << "00:00:00" << " - " << "23:59:59" << endl;
}
}
if (num > 1) {
for (int i = 0; i < num - 1; i++) {
if (times[i].end != times[i + 1].begin) {
cout << times[i].end << " - " << times[i + 1].begin << endl;
}
}
}
if (num >= 1) {
if (times[num - 1].end != "23:59:59") {
cout << times[num - 1].end << " - " << "23:59:59" << endl;
}
}
}