HDU1234 字符串处理

View Code
 1 #include<stdio.h>

 2 #include<string.h>

 3 const int inf = 9999999;

 4 struct node{

 5     int s,e;

 6     char m[ 24 ];

 7 }a[505];

 8 int main(){

 9     int t;

10     scanf("%d",&t);

11     while( t-- ){

12         int num;

13         char time[24];

14         scanf("%d",&num);

15         int ans1,ans2;

16         ans1=inf;

17         ans2=0;

18         int f1,f2;

19         for( int i=1;i<=num;i++ ){

20             scanf("%s",a[i].m);

21             scanf("%s",time);

22     //        s=m=h=0;

23             a[i].s=((time[0]-'0')*10+(time[1]-'0'))*3600+((time[3]-'0')*10+(time[4]-'0'))*60+((time[6]-'0')*10+time[7]-'0');

24             scanf("%s",time);

25             a[i].e=((time[0]-'0')*10+(time[1]-'0'))*3600+((time[3]-'0')*10+(time[4]-'0'))*60+((time[6]-'0')*10+time[7]-'0');

26             if( ans1>a[i].s ){

27                 ans1=a[i].s;

28                 f1=i;

29             }

30             if( ans2<a[i].e ){

31                 ans2=a[i].e;

32                 f2=i;

33             }

34         }

35         //sort( a+1,a+1+num,cmp );

36         printf("%s %s\n",a[f1].m,a[f2].m);

37     }

38     return 0;

39 }

 

你可能感兴趣的:(字符串处理)