Problem Type : Game
#include<stdio.h>
int main()
{
int t,player,age,a[100],i,j,k,less,great,p;
while(scanf("%d",&t)==1)
{
for(p=1; p<=t; p++)
{
scanf("%d",&player);
for(i=1; i<=player; i++)
{
scanf("%d",&a[i]);
}
for(j=1; j<=player; j++)
{
less=0;
great = 0;
for(k=1; k<=player; k++)
{
if( a[j]>a[k])
{
great++;
}
else if(a[j]<a[k])
{
less++;
}
}
if(less==great)
{
break;
}
}
printf("Case %d: %d\n",p,a[j]);
}
}
return 0;
}
#include<stdio.h>
int main()
{
int t,player,age,a[100],i,j,k,less,great,p;
while(scanf("%d",&t)==1)
{
for(p=1; p<=t; p++)
{
scanf("%d",&player);
for(i=1; i<=player; i++)
{
scanf("%d",&a[i]);
}
for(j=1; j<=player; j++)
{
less=0;
great = 0;
for(k=1; k<=player; k++)
{
if( a[j]>a[k])
{
great++;
}
else if(a[j]<a[k])
{
less++;
}
}
if(less==great)
{
break;
}
}
printf("Case %d: %d\n",p,a[j]);
}
}
return 0;
}
No comments:
Post a Comment