24h購物| | PChome| 登入
2009-01-18 13:45:41| 人氣1,386| 回應0 | 上一篇 | 下一篇

ACM 576 Haiku Review

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

注意事項:可能連續母音 這根本不合常理

可能輸入:aeiou eioua iouae ou o/eating bugs in the marshes/get indigestion

其解答為:Y

做法:1.先刪掉連續的母音,我用*當作刪除的數。

     2.判斷母音個數。

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

  1. #include<stdio.h>      
  2. #include<stdlib.h>   
  3. #include<string.h>   
  4. main()   
  5. {   
  6.   int a,b,c,temp=0,flag=0,time,time1=0;   
  7.   char x[200],y[6]="e/o/i";   
  8.   while(gets(x)!=0&&strcmp(x,y)!=0)   
  9.   {   
  10.    temp=0;time=0;flag=0;time1++;         
  11.    for(a=0;a<strlen(x);a++)   
  12.      {   
  13.       if(x[a]=='a'||x[a]=='e'||x[a]=='i'||x[a]=='o'||x[a]=='u'||x[a]=='y')      
  14.       while(x[a+1]=='a'||x[a+1]=='e'||x[a+1]=='i'||x[a+1]=='o'||x[a+1]=='u'||x[a+1]=='y')    
  15.        {   
  16.        x[a+1]='*';   
  17.        a++;   
  18.        }   
  19.      }    
  20.   for(a=0;a<strlen(x);a++)   
  21.    {       
  22.     if(x[a]!='/'&&(x[a]=='a'||x[a]=='e'||x[a]=='i'||x[a]=='o'||x[a]=='u'||x[a]=='y'))   
  23.      {   
  24.      temp++;   
  25.      }   
  26.     if(x[a]=='/')   
  27.      {   
  28.      if(flag!=0) break;   
  29.      time++;   
  30.      if(temp!=5&&time==1&&flag==0)   
  31.       flag=time;   
  32.      else if(temp!=7&&time==2&&flag==0)   
  33.       flag=time;   
  34.      temp=0;     
  35.      }    
  36.    }   
  37.    if(temp!=5&&flag==0)   
  38.     flag=time+1;   
  39.    if(flag==0)   
  40.     printf("Y\n");   
  41.    else  
  42.     printf("%d\n",flag);   
  43.   }   
  44.  return 0;        
  45. }

台長: 來源不明
人氣(1,386) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 數位資訊(科技、網路、通訊、家電) | 個人分類: ACM |
此分類下一篇:ACM 587 There’s treasure everywhere!
此分類上一篇:ACM 264 Count on Cantor

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