zoj 1698 Easier Done Than Said?

题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=698

题解:  额,水题一个,一点思维量都没有,就是逻辑判断理顺就好了。 耍赖使用了goto 

#include<iostream>
#include<string>
using namespace std;

int isvowel(char ch)
{
  if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
  return 1;
  else return 0;

}
int isconsonant(char ch)
{
  if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
  return 0;
  else return 1;

}

int main()
{
   string s;
   string ac="> is acceptable.";
   string wa="> is not acceptable.";

   while(cin>>s)
   {
       if(s=="end")  break;
       int bad=0;
       int size=s.length();

       int count=0;
       for(int i=0;i<size;i++)
       {
            if(isvowel(s[i]))
            {count++;
               break;
            }
       }

        if(count==0)
        {
            bad++;
            goto judge;
        }
       for(int i=0;i<size-1;i++)
          if(s[i]==s[i+1]&&!(s[i]=='e'||s[i]=='o'))
          {
             bad++;
             goto  judge;
          }
        for(int i=0;i<size-2;i++)
          if( isvowel(s[i])&&isvowel(s[i+1])&&isvowel(s[i+2]) ||(isconsonant(s[i])&&isconsonant(s[i+1])&&isconsonant(s[i+2])))
          {
             bad++;
             goto  judge;
          }




       judge: if(bad==0)
       cout<<"<"<<s<<ac<<endl;
       else
       cout<<"<"<<s<<wa<<endl;
   }
}


posted @ 2013-07-28 21:35  814jingqi  阅读(152)  评论(0编辑  收藏  举报