PATA -1006 Sign In and Sign Out
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<stdio.h> #include<string.h> using namespace std; struct t{ int h,m,s; t(){h=0;m=0;s=0;} }; struct t tranvert(char[]); int comparet(char [],char []); int main(){ int M; scanf("%d",&M); char n[20],timein[20],timeout[20]; char resnin[20],resnout[20]; char restimein[20],restimeout[20]; scanf("%s %s %s",n,timein,timeout); strcpy(resnin,n); strcpy(resnout,n); strcpy(restimein,timein); strcpy(restimeout,timeout); for(int i=1;i<M;i++){ scanf("%s %s %s",n,timein,timeout); if(comparet(timein,restimein)<0){ strcpy(resnin,n); strcpy(restimein,timein); } if(comparet(timeout,restimeout)>0){ strcpy(resnout,n); strcpy(restimeout,timeout); } } printf("%s %s",resnin,resnout); return 0; } struct t tranvert(char a[20]){ struct t t1; t1.h = (a[0]-'0')* 10 + (a[1]-'0'); t1.m = (a[3]-'0')* 10 + (a[4]-'0'); t1.s = (a[6]-'0') * 10 + (a[7]-'0'); return t1; } int comparet(char t1[20],char t2[20]){ struct t tt1,tt2; tt1 = tranvert(t1); tt2 = tranvert(t2); if(tt1.h>tt2.h) return 1; else if(tt1.h==tt2.h){ if(tt1.m==tt2.m){ if(tt1.s==tt2.s) return 0; else if(tt1.s>tt2.s) return 1; else return -1; }else if(tt1.m>tt2.m) return 1; else return -1; } else return -1; }