Check Words:
It should be filtered by:
-->> It must contain at least one vowel.
-->> It cannot contain three consecutive vowels or three consecutive consonants.
-->> It cannot contain two consecutive occurrences of the same letter, except for 'ee' or 'oo'.
Set a flag, and check three times by three functions and figure out whether the words is corresponse with the given filter
<a> is acceptable. <tv> is not acceptable. <ptoui> is not acceptable. <bontres> is not acceptable. <zoggax> is not acceptable. <wiinq> is not acceptable. <eep> is acceptable. <houctuh> is acceptable.***********************************************
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[25];
int iPut;
bool fIsVowel(char key);
void fCheck(char a[]);
void fCheckB(char a[]);
void fCheckC(char a[]);
int main() {
while(true) {
cin >> a;
if(!strcmp(a, "end"))
return 0;
iPut = 1; //Default as pass;
fCheck(a);
if(iPut)
fCheckB(a);
if(iPut)
fCheckC(a);
if(iPut)
cout << "<" << a << "> is acceptable." << endl;
else
cout << "<" << a << "> is not acceptable." << endl;
}
return 0;
}
void fCheck(char a[]) {
for(int i = 0; i < strlen(a); i++) {
if(fIsVowel(a[i])) {
return;
}
}
//if not vowel is found, set output is false;
iPut = 0;
}
void fCheckB(char a[]) {
int iFlagA = 0;
int iFlagB = 0;
for(int i = 0; i < strlen(a); i++) {
if(fIsVowel(a[i])) {
iFlagA++;
iFlagB = 0;
}
else {
iFlagB++;
iFlagA = 0;
}
if(iFlagA == 3 || iFlagB == 3) {
iPut = 0;
return;
}
}
}
void fCheckC(char a[]) {
char cPrevious = a[0];
for(int i = 1; i < strlen(a); i++) {
if(a[i] == cPrevious && a[i] != 'e' && a[i] != 'o') {
iPut = 0;
return;
}
cPrevious = a[i];
}
}
bool fIsVowel(char key) {
return key == 'a' || key == 'e' || key == 'i' || key == 'o' || key == 'u';
}