pat 1006

水题,没什么好说的

http://pat.zju.edu.cn/contests/pat-a-practise/1006

View Code
 1 #include<stdio.h>

 2 #include<string.h>

 3 

 4 struct node

 5 {

 6     char ID[16];

 7     char in_time[10];

 8     char out_time[10];

 9 }records[200];

10 int M;

11 int main()

12 {

13     int i,min, max;

14     int flag = 0; 

15     while(scanf("%d", &M)!= EOF){

16         for(i= 0; i< M; i++)

17         {

18             scanf("%s %s %s", records[i].ID, records[i].in_time,records[i].out_time) ;

19         }

20         

21         min = max =0;

22         for(i = 1; i< M; i++){

23 

24             if(strcmp(records[i].in_time, records[min].in_time) < 0) min = i;

25             if(strcmp(records[max].out_time, records[i].out_time)< 0 ) max = i;

26 

27         }

28         if(1 == flag) 

29             printf("\n");

30         else

31             flag = 1;

32         printf("%s %s",records[min].ID, records[max].ID) ;

33 

34     }// end of while 

35 

36     return 0;

37 }

 

你可能感兴趣的:(pat)