Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- bool two(string n)
- {
- bool check=true;
- for(int i=0; i<n.size()-1; i++)
- {
- if(n[i]==n[i+1] && n[i]!='e' && n[i]!='o')
- {
- check=false;
- break;
- }
- }
- return check;
- }
- bool threes(string n, string arr)
- {
- bool check=true;
- int num=0;
- int sum=0;
- if(n.size()>=3)
- {
- for(int i=0; i<n.size(); i++)
- {
- check=false;
- for(int k=0; k<5; k++)
- {
- if(n[i]==arr[k])
- {
- check=true;
- break;
- }
- }
- if(check)
- {
- sum=0;
- num++;
- }
- else
- {
- num=0;
- sum++;
- }
- if(num==3 || sum==3)
- {
- check=false;
- break;
- }
- else
- {
- check=true;
- }
- }
- }
- return check;
- }
- int main() {
- string n="\0";
- string a="aeiou";
- while(1)
- {
- cin>>n;
- if(n=="end")
- break;
- int num=0;
- for(int i=0; i<n.size(); i++)
- {
- if(num>=1)
- break;
- for(int k=0; k<5; k++)
- {
- if(n[i]==a[k])
- {
- num++;
- break;
- }
- }
- }
- if(num!=0 && two(n) && threes(n,a))
- cout<<"<"<<n<<"> is acceptable."<<endl;
- else
- cout<<"<"<<n<<"> is not acceptable."<<endl;
- }
- }
Add Comment
Please, Sign In to add comment