HDU 1234 开门人与关门人

#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    { char a[1000][16];
      int i,m,s1,s2;
       scanf("%d",&m);
       s1=1;
       s2=2;
      for(i=0;i<m*3;i++) 
      {  scanf("%s",a[i]);       }
      for(i=4;i<m*3;i+=3)
      { 
        if(strcmp(a[i],a[1])<0)
        {strcpy(a[1],a[i]);                   
               s1=i;}
      }
       for(i=5;i<m*3;i+=3)
      { 
        if(strcmp(a[i],a[2])>0)
          {
          strcpy(a[2],a[i]);
               s2=i;
           }
        }    
       printf("%s %s\n",a[s1-1],a[s2-2]);    
    }
    return 0;
}

posted @ 2013-07-28 17:05  hpu张亚飞  阅读(116)  评论(0)    收藏  举报