Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The new soulution of Exercise 5.12 #200

Open
xixiyu5 opened this issue Jul 19, 2021 · 0 comments
Open

The new soulution of Exercise 5.12 #200

xixiyu5 opened this issue Jul 19, 2021 · 0 comments

Comments

@xixiyu5
Copy link

xixiyu5 commented Jul 19, 2021

#include

using namespace std;

int main() {
unsigned int aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0,fCnt=0, ffCnt = 0, flCnt = 0, fiCnt = 0,spaceCnt=0,tabCnt=0,newlinesCnt=0;
char ch;
cout << "请输入一段文本:" << endl;
while (cin.get(ch) ){
switch (ch) {
case 'a':
case 'A':
++aCnt;
break;
case 'e':
case 'E':
++eCnt;
break;
case 'o':
case 'O':
++oCnt;
break;
case 'u':
case 'U':
++uCnt;
break;
case'\t':
++tabCnt;
break;
case'\n':
++newlinesCnt;
break;
case' ':
++spaceCnt;
break;
case'f': {
if (fCnt == 1) {
ffCnt++;
fCnt = 0;
break;
}
fCnt++;
}
break;
case'l':
if (fCnt == 1) {
flCnt++;
fCnt = 0;
}
break;
case'i':
if (fCnt == 1) {
fiCnt++;
fCnt = 0;
}

    }
}
cout << "元音字母 a 的数量是:" << aCnt << endl;
cout << "元音字母 e 的数量是:" << eCnt << endl;
cout << "元音字母 i 的数量是:" << iCnt << endl;
cout << "元音字母 o 的数量是:" << oCnt << endl;
cout << "ffCnt 的数量是:" << ffCnt << endl;
cout << "flCnt 的数量是:" << flCnt << endl;
cout << "fiCnt 的数量是:" << fiCnt << endl;


return 0;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant