暑假第二天
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;
}
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
2023-07-06 第二周第五天