2009-01-15 16:48:11來源不明
2008 NPSC A. 犯人的編號
/**********************************************************/
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- main()
- {
- char t[10];/*輸入的值*/
- char x[1000],y[1000];
- int a,b,c,n,tempA,tempB;
- while(gets(t)!=0)
- {
- scanf("%d ",&n);
- for(a=0;a<n;a++)
- {
- gets(x);
- tempA=0;tempB=0;
- for(b=0;b<4;b++)
- {
- for(c=0;c<4;c++)
- {
- if(t[b]==x[c]&&b==c)
- {tempA++;x[c]=0;break;}
- if(t[b]==x[c]&&b!=c)
- {tempB++;x[c]=0;break;}
- }
- }
- printf("%dA%dB\n",tempA,tempB);
- }
- }
- return 0;
- }