hdu 1234 开门人和关门人
这个地方要用string.h中的几个函数,特别是strcmp,可以比较两个时间;
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct e
{
char s1[20],s2[20],s3[20];
}p[1000005];
int main( )
{
int t,n;
scanf( "%d",&t );
while( t-- )
{
scanf( "%d",&n );
for( int i = 0; i < n; ++i )
scanf( "%s%s%s",p[i].s1,p[i].s2,p[i].s3 );
int p1,p2;
p1 = p2 = 0;
for( int i = 0; i < n; ++i )
{
if( strcmp( p[i].s2,p[p1].s2 ) < 0 )
p1 = i;
if( strcmp( p[i].s3,p[p2].s3 ) > 0 )
p2 = i;
}
printf( "%s %s\n",p[p1].s1,p[p2].s1 );
}
return 0;
}
本人还是新手 ,转载请注明来自Lvsi‘s home
浙公网安备 33010602011771号