24h購物| | PChome| 登入
2009-01-15 16:41:42| 人氣480| 回應0 | 上一篇 | 下一篇

2008 NPSC B. 首領的名字

推薦 0 收藏 0 轉貼0 訂閱站台

比#前後的字母!

/******************************************************/

  1. #include<stdio.h>      
  2. #include<stdlib.h>   
  3. #include<string.h>   
  4. main()   
  5. {   
  6.  int n,m,a,b,c,d,temp,time,time1,temp1,k;   
  7.  char x[100],y[100];   
  8.   while(scanf("%d ",&n)==1)   
  9.    {        
  10.     for(a=1;a<=n;a++)   
  11.      {   
  12.       gets(x);   
  13.       printf("DATA SET #%d:\n",a);   
  14.       scanf("%d ",&m);   
  15.       for(c=0;c<m;c++)   
  16.        {   
  17.         gets(y);temp=0;time=0;temp1=0;time1=0;   
  18.         k=strlen(y)-1;   
  19.         for(b=0;b<strlen(x);b++)   
  20.          {   
  21.           if(x[b]!='#')            /*比頭*/  
  22.            {   
  23.             if(x[b]==y[b])   
  24.              {temp++;}   
  25.             time++;   
  26.            }   
  27.           if(x[b]=='#')   
  28.            break;    
  29.          }   
  30.         for(b=strlen(x)-1;b>0;b--)   
  31.          {   
  32.           if(x[b]!='#')            /*比尾*/  
  33.            {   
  34.             if(x[b]==y[k])   
  35.              {temp1++;k--;}   
  36.             time1++;   
  37.            }   
  38.           if(x[b]=='#')   
  39.            break;    
  40.          }    
  41.             
  42.         if(time+time1==temp1+temp)   
  43.          printf("POSSIBLE\n");   
  44.         else  
  45.          printf("IMPOSSIBLE\n");     
  46.        }      
  47.      }   
  48.    }     
  49.  return 0;        
  50. } 

台長: 來源不明
人氣(480) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 數位資訊(科技、網路、通訊、家電) | 個人分類: NPSC |
此分類下一篇:2008 NPSC C. 電費系統
此分類上一篇:2008 NPSC A. 優惠方案

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文