2009-01-15 16:41:42來源不明
2008 NPSC B. 首領的名字
比#前後的字母!
/******************************************************/
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- main()
- {
- int n,m,a,b,c,d,temp,time,time1,temp1,k;
- char x[100],y[100];
- while(scanf("%d ",&n)==1)
- {
- for(a=1;a<=n;a++)
- {
- gets(x);
- printf("DATA SET #%d:\n",a);
- scanf("%d ",&m);
- for(c=0;c<m;c++)
- {
- gets(y);temp=0;time=0;temp1=0;time1=0;
- k=strlen(y)-1;
- for(b=0;b<strlen(x);b++)
- {
- if(x[b]!='#') /*比頭*/
- {
- if(x[b]==y[b])
- {temp++;}
- time++;
- }
- if(x[b]=='#')
- break;
- }
- for(b=strlen(x)-1;b>0;b--)
- {
- if(x[b]!='#') /*比尾*/
- {
- if(x[b]==y[k])
- {temp1++;k--;}
- time1++;
- }
- if(x[b]=='#')
- break;
- }
- if(time+time1==temp1+temp)
- printf("POSSIBLE\n");
- else
- printf("IMPOSSIBLE\n");
- }
- }
- }
- return 0;
- }