HDU 1039 字符串处理
小水题一道,关键是第二个要求中状态的转移 hehhe
/*
* Author:loneylycatcher
* problem:hdu 1039
* Type:字符串处理
*/
#include <iostream>
#include<string.h>
#include<stdio.h>
#include<cstdlib>
using namespace std;
string s;
int main()
{
setbuf(stdout,NULL);
int i;
while(cin>>s)
{
if(s.compare("end")==0)break;
int len=s.length();
int yuanyin=0;
int fuyin=0;
for(i=0;i<len;i++)
{
if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u')
{
yuanyin++;
}
else
{
fuyin++;
}
}
if(yuanyin==0)
{
cout<<"<"<<s<<">"<<" is not acceptable."<<endl;
continue;
}
yuanyin=0;
fuyin=0;
for(i=0;i<len;i++)
{
if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u')
{
yuanyin++;
fuyin=0;
if(yuanyin==3)break;
}
else
{
fuyin++;
yuanyin=0;
if(fuyin==3)break;
}
}
if(yuanyin==3||fuyin==3)
{
cout<<"<"<<s<<">"<<" is not acceptable."<<endl;
continue;
}
int flag=0;
for(i=1;i<len;i++)
{
if(s[i]==s[i-1]&&s[i]!='e'&&s[i]!='o')
{
flag=1;
break;
}
}s
if(flag)
{
cout<<"<"<<s<<">"<<" is not acceptable."<<endl;
continue;
}
cout<<"<"<<s<<">"<<" is acceptable."<<endl;
}
return 0;
}
posted on 2011-08-01 14:46 lonelycatcher 阅读(299) 评论(0) 编辑 收藏 举报