#include<stdio.h>
int main()
{
long int ary[100][100],count[100],i,j,small,p,q,z;
int flag;
while(1)
{ flag=1;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
z=scanf("%ld",&ary[i][j]);
if(z==EOF)
{
flag=0;
break;
}
}
}
if(flag==0)
break;
count[1]=ary[1][2]+ary[1][3]+ary[2][1]+ary[2][2]+ary[3][1]+ary[3][3];
count[2]=ary[1][2]+ary[1][3]+ary[2][1]+ary[2][3]+ary[3][1]+ary[3][2];
count[3]=ary[1][1]+ary[1][2]+ary[2][2]+ary[2][3]+ary[3][1]+ary[3][3];
count[4]=ary[1][1]+ary[1][2]+ary[2][1]+ary[2][3]+ary[3][2]+ary[3][3];
count[5]=ary[1][1]+ary[1][3]+ary[2][2]+ary[2][3]+ary[3][1]+ary[3][2];
count[6]=ary[1][1]+ary[1][3]+ary[2][1]+ary[2][2]+ary[3][2]+ary[3][3];
small=count[1];
p=1;
for(q=2;q<=6;q++)
{
if(small>count[q])
{
small=count[q];
p=q;
}
}
if (p==1)
printf("BCG %ld\n",small);
else if(p==2)
printf("BGC %ld\n",small);
else if (p==3)
printf("CBG %ld\n",small);
else if (p==4)
printf("CGB %ld\n",small);
else if (p==5)
printf("GBC %ld\n",small);
else if (p==6)
printf("GCB %ld\n",small);
}
return 0;
}
int main()
{
long int ary[100][100],count[100],i,j,small,p,q,z;
int flag;
while(1)
{ flag=1;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
z=scanf("%ld",&ary[i][j]);
if(z==EOF)
{
flag=0;
break;
}
}
}
if(flag==0)
break;
count[1]=ary[1][2]+ary[1][3]+ary[2][1]+ary[2][2]+ary[3][1]+ary[3][3];
count[2]=ary[1][2]+ary[1][3]+ary[2][1]+ary[2][3]+ary[3][1]+ary[3][2];
count[3]=ary[1][1]+ary[1][2]+ary[2][2]+ary[2][3]+ary[3][1]+ary[3][3];
count[4]=ary[1][1]+ary[1][2]+ary[2][1]+ary[2][3]+ary[3][2]+ary[3][3];
count[5]=ary[1][1]+ary[1][3]+ary[2][2]+ary[2][3]+ary[3][1]+ary[3][2];
count[6]=ary[1][1]+ary[1][3]+ary[2][1]+ary[2][2]+ary[3][2]+ary[3][3];
small=count[1];
p=1;
for(q=2;q<=6;q++)
{
if(small>count[q])
{
small=count[q];
p=q;
}
}
if (p==1)
printf("BCG %ld\n",small);
else if(p==2)
printf("BGC %ld\n",small);
else if (p==3)
printf("CBG %ld\n",small);
else if (p==4)
printf("CGB %ld\n",small);
else if (p==5)
printf("GBC %ld\n",small);
else if (p==6)
printf("GCB %ld\n",small);
}
return 0;
}
No comments:
Post a Comment