| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
小白求教#include<stdio.h>
int main()
{
char ch[20][10];
int i,j,k,l,m,n;
while(scanf("%s",ch[0])!=EOF)
{
for(l=0,i=1;i<12;i++)
scanf("%s",ch[i]);
printf("CARDS: %s",ch[0]);
for(i=1;i<12;i++) printf(" %s",ch[i]);
printf("\n");
for(i=0;i<10;i++)
for(j=i+1;j<11;j++)
for(k=j+1;k<12;k++)
{
for(n=m=0;m<4;m++)
if((ch[i][m]==ch[j][m]&&ch[i][m]==ch[k][m])||(ch[i][m]!=ch[j][m]&&ch[i][m]!=ch[k][m]&&ch[j][m]!=ch[k][m])) n++;
if(n!=4) continue;
if(!l) printf("SETS: %d. %s %s %s\n",++l,ch[i],ch[j],ch[k]);
else printf(" %d. %s %s %s\n",++l,ch[i],ch[j],ch[k]);
}
if(!l) printf("SETS: *** None Found ***");
printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator