整了一个看起来像是时间表的东西。
//g++ test3_clock.cpp -o test3_clock -g -std=c++14 -O0 -Wall -fsanitize=undefined
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<chrono>
#include<windows.h>
#define LL long long
using namespace std;
const int maxn=1e6;
int qd(){
char c=getchar();int rt=0;
while(c!=EOF&&(c<'0'||c>'9')) c=getchar();
while('0'<=c&&c<='9') rt=rt*10+c-48,c=getchar();
return c==EOF?-1:rt;
}
struct node{
int tp,mon,d,h,m,s,s_begin;
node(){tp=mon=d=h=m=s=s_begin=0;}
node(const int &_tp,const int &_mon,const int &_d,const int &_h,const int &_m,const int &_s,const int &_s_begin){
tp=_tp,mon=_mon,d=_d,h=_h,m=_m,s=_s,s_begin=_s_begin;
}
bool operator<(const node &x){
if(mon!=x.mon) return mon<x.mon;
if(d!=x.d) return d<x.d;
if(h!=x.h) return h<x.h;
if(m!=x.m) return m<x.m;
if(s!=x.s) return s<x.s;
return tp<x.tp;
}
}f[maxn];
char str[maxn];int ftop=0,stop=0,ftil=0;
int qsd(){
char c=getchar();int rt=stop;
while(c==' '||c=='\r'||c=='\n') c=getchar();
while(c!='\r'&&c!='\n') str[stop++]=c,c=getchar();
str[stop++]=0;return rt;
}
node ntime(){
auto tt=chrono::system_clock::to_time_t(chrono::system_clock::now());struct tm* rt=localtime(&tt);
// printf("%lld\n",rt->tm_mon);return node();
return node(0,rt->tm_mon+1,rt->tm_mday,rt->tm_hour,rt->tm_min,rt->tm_sec,0);
}
void showword(){
system("cls");
node x=ntime();printf("%d-%d %d:%d:%d\n%s\n",x.mon,x.d,x.h,x.m,x.s,str+f[ftil-1].s_begin);
fflush(stdout);
}
void ring(int t){
if(t==1){
Beep(659,300);Beep(523,300);Beep(578,300);Beep(392,300);Sleep(2000);
Beep(392,300);Beep(578,300);Beep(659,300);Beep(523,300);Sleep(1000);
}
else if(t==2){
Beep(392,300);Beep(578,300);Beep(659,300);Beep(523,300);Sleep(2000);
Beep(659,300);Beep(523,300);Beep(578,300);Beep(392,300);Sleep(1000);
}
else if(t==3){
Beep(523,300);Beep(659,300);Beep(784,300);Beep(1046,500);Sleep(1000);
}
}
void work0(){
ring(1);
printf("end\n");fflush(stdout);
}
int main(){
freopen("timeplan.txt","r",stdin);
while(1){
int tp=qd();if(tp==-1) break;
f[++ftop].tp=tp;
f[ftop].mon=qd();
f[ftop].d=qd();
f[ftop].h=qd();
f[ftop].m=qd();
f[ftop].s=qd();
f[ftop].s_begin=qsd();
}
fclose(stdin);
sort(f+1,f+ftop+1);
++ftil;while(f[ftil]<ntime()) ftil++;
while(ftil<=ftop){
showword();Sleep(500);if(ntime()<f[ftil]) continue;
showword();ring(f[++ftil].tp);
}
return 0;
}
另附输入数据 timeplan.txt
<1> 2-4 6:00:00 on class
<2> 2-4 6:50:00 free
<1> 2-4 7:00:00 on class
<2> 2-4 7:50:00 free
<1> 2-4 8:00:00 on class
<2> 2-4 8:50:00 free
<1> 2-4 9:00:00 on class
<2> 2-4 9:50:00 free
<1> 2-4 10:00:00 on class
<2> 2-4 10:50:00 free
<1> 2-4 11:00:00 on class
<3> 2-4 12:00:00 end
<1> 2-4 14:00:00 on class
<2> 2-4 14:50:00 free
<1> 2-4 15:00:00 on class
<2> 2-4 15:50:00 free
<1> 2-4 16:00:00 on class
<2> 2-4 16:50:00 free
<1> 2-4 17:00:00 on class
<3> 2-4 18:00:00 end
<1> 2-4 19:00:00 on class
<2> 2-4 19:50:00 free
<1> 2-4 20:00:00 on class
<2> 2-4 20:50:00 free
<1> 2-4 21:00:00 on class
<2> 2-4 21:50:00 free
<1> 2-4 22:00:00 on class
<3> 2-4 22:40:00 end
<1> 2-5 6:00:00 on class
<2> 2-5 6:50:00 free
<1> 2-5 7:00:00 on class
<2> 2-5 7:50:00 free
<1> 2-5 8:00:00 on class
<2> 2-5 8:50:00 free
<1> 2-5 9:00:00 on class
<2> 2-5 9:50:00 free
<1> 2-5 10:00:00 on class
<2> 2-5 10:50:00 free
<1> 2-5 11:00:00 on class
<3> 2-5 12:00:00 end
<1> 2-5 14:00:00 on class
<2> 2-5 14:50:00 free
<1> 2-5 15:00:00 on class
<2> 2-5 15:50:00 free
<1> 2-5 16:00:00 on class
<2> 2-5 16:50:00 free
<1> 2-5 17:00:00 on class
<3> 2-5 18:00:00 end
<1> 2-5 19:00:00 on class
<2> 2-5 19:50:00 free
<1> 2-5 20:00:00 on class
<2> 2-5 20:50:00 free
<1> 2-5 21:00:00 on class
<2> 2-5 21:50:00 free
<1> 2-5 22:00:00 on class
<3> 2-5 22:40:00 end
<1> 2-6 6:00:00 on class
<2> 2-6 6:50:00 free
<1> 2-6 7:00:00 on class
<2> 2-6 7:50:00 free
<1> 2-6 8:00:00 on class
<2> 2-6 8:50:00 free
<1> 2-6 9:00:00 on class
<2> 2-6 9:50:00 free
<1> 2-6 10:00:00 on class
<2> 2-6 10:50:00 free
<1> 2-6 11:00:00 on class
<3> 2-6 12:00:00 end
<1> 2-6 14:00:00 on class
<2> 2-6 14:50:00 free
<1> 2-6 15:00:00 on class
<2> 2-6 15:50:00 free
<1> 2-6 16:00:00 on class
<2> 2-6 16:50:00 free
<1> 2-6 17:00:00 on class
<3> 2-6 18:00:00 end
<1> 2-6 19:00:00 on class
<2> 2-6 19:50:00 free
<1> 2-6 20:00:00 on class
<2> 2-6 20:50:00 free
<1> 2-6 21:00:00 on class
<2> 2-6 21:50:00 free
<1> 2-6 22:00:00 on class
<3> 2-6 22:40:00 end
<1> 2-7 6:00:00 on class
<2> 2-7 6:50:00 free
<1> 2-7 7:00:00 on class
<2> 2-7 7:50:00 free
<1> 2-7 8:00:00 on class
<2> 2-7 8:50:00 free
<1> 2-7 9:00:00 on class
<2> 2-7 9:50:00 free
<1> 2-7 10:00:00 on class
<2> 2-7 10:50:00 free
<1> 2-7 11:00:00 on class
<3> 2-7 12:00:00 end
<1> 2-7 14:00:00 on class
<2> 2-7 14:50:00 free
<1> 2-7 15:00:00 on class
<2> 2-7 15:50:00 free
<1> 2-7 16:00:00 on class
<2> 2-7 16:50:00 free
<1> 2-7 17:00:00 on class
<3> 2-7 18:00:00 end
<1> 2-7 19:00:00 on class
<2> 2-7 19:50:00 free
<1> 2-7 20:00:00 on class
<2> 2-7 20:50:00 free
<1> 2-7 21:00:00 on class
<2> 2-7 21:50:00 free
<1> 2-7 22:00:00 on class
<3> 2-7 22:40:00 end
<1> 2-8 6:00:00 on class
<2> 2-8 6:50:00 free
<1> 2-8 7:00:00 on class
<2> 2-8 7:50:00 free
<1> 2-8 8:00:00 on class
<2> 2-8 8:50:00 free
<1> 2-8 9:00:00 on class
<2> 2-8 9:50:00 free
<1> 2-8 10:00:00 on class
<2> 2-8 10:50:00 free
<1> 2-8 11:00:00 on class
<3> 2-8 12:00:00 end
<1> 2-8 14:00:00 on class
<2> 2-8 14:50:00 free
<1> 2-8 15:00:00 on class
<2> 2-8 15:50:00 free
<1> 2-8 16:00:00 on class
<2> 2-8 16:50:00 free
<1> 2-8 17:00:00 on class
<3> 2-8 18:00:00 end
<1> 2-8 19:00:00 on class
<2> 2-8 19:50:00 free
<1> 2-8 20:00:00 on class
<2> 2-8 20:50:00 free
<1> 2-8 21:00:00 on class
<2> 2-8 21:50:00 free
<1> 2-8 22:00:00 on class
<3> 2-8 22:40:00 end
<1> 2-9 6:00:00 on class
<2> 2-9 6:50:00 free
<1> 2-9 7:00:00 on class
<2> 2-9 7:50:00 free
<1> 2-9 8:00:00 on class
<2> 2-9 8:50:00 free
<1> 2-9 9:00:00 on class
<2> 2-9 9:50:00 free
<1> 2-9 10:00:00 on class
<2> 2-9 10:50:00 free
<1> 2-9 11:00:00 on class
<3> 2-9 12:00:00 end
<1> 2-9 14:00:00 on class
<2> 2-9 14:50:00 free
<1> 2-9 15:00:00 on class
<2> 2-9 15:50:00 free
<1> 2-9 16:00:00 on class
<2> 2-9 16:50:00 free
<1> 2-9 17:00:00 on class
<3> 2-9 18:00:00 end
<1> 2-9 19:00:00 on class
<2> 2-9 19:50:00 free
<1> 2-9 20:00:00 on class
<2> 2-9 20:50:00 free
<1> 2-9 21:00:00 on class
<2> 2-9 21:50:00 free
<1> 2-9 22:00:00 on class
<3> 2-9 22:40:00 end
<1> 2-9 6:00:00 on class
<2> 2-10 6:50:00 free
<1> 2-10 7:00:00 on class
<2> 2-10 7:50:00 free
<1> 2-10 8:00:00 on class
<2> 2-10 8:50:00 free
<1> 2-10 9:00:00 on class
<2> 2-10 9:50:00 free
<1> 2-10 10:00:00 on class
<2> 2-10 10:50:00 free
<1> 2-10 11:00:00 on class
<3> 2-10 12:00:00 end
<1> 2-10 14:00:00 on class
<2> 2-10 14:50:00 free
<1> 2-10 15:00:00 on class
<2> 2-10 15:50:00 free
<1> 2-10 16:00:00 on class
<2> 2-10 16:50:00 free
<1> 2-10 17:00:00 on class
<3> 2-10 18:00:00 end
<1> 2-10 19:00:00 on class
<2> 2-10 19:50:00 free
<1> 2-10 20:00:00 on class
<2> 2-10 20:50:00 free
<1> 2-10 21:00:00 on class
<2> 2-10 21:50:00 free
<1> 2-10 22:00:00 on class
<3> 2-10 22:40:00 end
<1> 2-11 6:00:00 on class
<2> 2-11 6:50:00 free
<1> 2-11 7:00:00 on class
<2> 2-11 7:50:00 free
<1> 2-11 8:00:00 on class
<2> 2-11 8:50:00 free
<1> 2-11 9:00:00 on class
<2> 2-11 9:50:00 free
<1> 2-11 10:00:00 on class
<2> 2-11 10:50:00 free
<1> 2-11 11:00:00 on class
<3> 2-11 12:00:00 end
<1> 2-11 14:00:00 on class
<2> 2-11 14:50:00 free
<1> 2-11 15:00:00 on class
<2> 2-11 15:50:00 free
<1> 2-11 16:00:00 on class
<2> 2-11 16:50:00 free
<1> 2-11 17:00:00 on class
<3> 2-11 18:00:00 end
<1> 2-11 19:00:00 on class
<2> 2-11 19:50:00 free
<1> 2-11 20:00:00 on class
<2> 2-11 20:50:00 free
<1> 2-11 21:00:00 on class
<2> 2-11 21:50:00 free
<1> 2-11 22:00:00 on class
<3> 2-11 22:40:00 end
<1> 2-12 6:00:00 on class
<2> 2-12 6:50:00 free
<1> 2-12 7:00:00 on class
<2> 2-12 7:50:00 free
<1> 2-12 8:00:00 on class
<2> 2-12 8:50:00 free
<1> 2-12 9:00:00 on class
<2> 2-12 9:50:00 free
<1> 2-12 10:00:00 on class
<2> 2-12 10:50:00 free
<1> 2-12 11:00:00 on class
<3> 2-12 12:00:00 end
<1> 2-12 14:00:00 on class
<2> 2-12 14:50:00 free
<1> 2-12 15:00:00 on class
<2> 2-12 15:50:00 free
<1> 2-12 16:00:00 on class
<2> 2-12 16:50:00 free
<1> 2-12 17:00:00 on class
<3> 2-12 18:00:00 end
<1> 2-12 19:00:00 on class
<2> 2-12 19:50:00 free
<1> 2-12 20:00:00 on class
<2> 2-12 20:50:00 free
<1> 2-12 21:00:00 on class
<2> 2-12 21:50:00 free
<1> 2-12 22:00:00 on class
<3> 2-12 22:40:00 end
<1> 2-13 6:00:00 on class
<2> 2-13 6:50:00 free
<1> 2-13 7:00:00 on class
<2> 2-13 7:50:00 free
<1> 2-13 8:00:00 on class
<2> 2-13 8:50:00 free
<1> 2-13 9:00:00 on class
<2> 2-13 9:50:00 free
<1> 2-13 10:00:00 on class
<2> 2-13 10:50:00 free
<1> 2-13 11:00:00 on class
<3> 2-13 12:00:00 end
<1> 2-13 14:00:00 on class
<2> 2-13 14:50:00 free
<1> 2-13 15:00:00 on class
<2> 2-13 15:50:00 free
<1> 2-13 16:00:00 on class
<2> 2-13 16:50:00 free
<1> 2-13 17:00:00 on class
<3> 2-13 18:00:00 end
<1> 2-13 19:00:00 on class
<2> 2-13 19:50:00 free
<1> 2-13 20:00:00 on class
<2> 2-13 20:50:00 free
<1> 2-13 21:00:00 on class
<2> 2-13 21:50:00 free
<1> 2-13 22:00:00 on class
<3> 2-13 22:40:00 end
<1> 2-14 6:00:00 on class
<2> 2-14 6:50:00 free
<1> 2-14 7:00:00 on class
<2> 2-14 7:50:00 free
<1> 2-14 8:00:00 on class
<2> 2-14 8:50:00 free
<1> 2-14 9:00:00 on class
<2> 2-14 9:50:00 free
<1> 2-14 10:00:00 on class
<2> 2-14 10:50:00 free
<1> 2-14 11:00:00 on class
<3> 2-14 12:00:00 end
<1> 2-14 14:00:00 on class
<2> 2-14 14:50:00 free
<1> 2-14 15:00:00 on class
<2> 2-14 15:50:00 free
<1> 2-14 16:00:00 on class
<2> 2-14 16:50:00 free
<1> 2-14 17:00:00 on class
<3> 2-14 18:00:00 end
<1> 2-14 19:00:00 on class
<2> 2-14 19:50:00 free
<1> 2-14 20:00:00 on class
<2> 2-14 20:50:00 free
<1> 2-14 21:00:00 on class
<2> 2-14 21:50:00 free
<1> 2-14 22:00:00 on class
<3> 2-14 22:40:00 end
<1> 2-15 6:00:00 on class
<2> 2-15 6:50:00 free
<1> 2-15 7:00:00 on class
<2> 2-15 7:50:00 free
<1> 2-15 8:00:00 on class
<2> 2-15 8:50:00 free
<1> 2-15 9:00:00 on class
<2> 2-15 9:50:00 free
<1> 2-15 10:00:00 on class
<2> 2-15 10:50:00 free
<1> 2-15 11:00:00 on class
<3> 2-15 12:00:00 end
<1> 2-15 14:00:00 on class
<2> 2-15 14:50:00 free
<1> 2-15 15:00:00 on class
<2> 2-15 15:50:00 free
<1> 2-15 16:00:00 on class
<2> 2-15 16:50:00 free
<1> 2-15 17:00:00 on class
<3> 2-15 18:00:00 end
<1> 2-15 19:00:00 on class
<2> 2-15 19:50:00 free
<1> 2-15 20:00:00 on class
<2> 2-15 20:50:00 free
<1> 2-15 21:00:00 on class
<2> 2-15 21:50:00 free
<1> 2-15 22:00:00 on class
<3> 2-15 22:40:00 end
<1> 2-16 6:00:00 on class
<2> 2-16 6:50:00 free
<1> 2-16 7:00:00 on class
<2> 2-16 7:50:00 free
<1> 2-16 8:00:00 on class
<2> 2-16 8:50:00 free
<1> 2-16 9:00:00 on class
<2> 2-16 9:50:00 free
<1> 2-16 10:00:00 on class
<2> 2-16 10:50:00 free
<1> 2-16 11:00:00 on class
<3> 2-16 12:00:00 end
<1> 2-16 14:00:00 on class
<2> 2-16 14:50:00 free
<1> 2-16 15:00:00 on class
<2> 2-16 15:50:00 free
<1> 2-16 16:00:00 on class
<2> 2-16 16:50:00 free
<1> 2-16 17:00:00 on class
<3> 2-16 18:00:00 end
<1> 2-16 19:00:00 on class
<2> 2-16 19:50:00 free
<1> 2-16 20:00:00 on class
<2> 2-16 20:50:00 free
<1> 2-16 21:00:00 on class
<2> 2-16 21:50:00 free
<1> 2-16 22:00:00 on class
<3> 2-16 22:40:00 end
标签:00,15,14,时间表,50,free,class
From: https://www.cnblogs.com/hbhz-zcy/p/18006741