forked from pezy/CppPrimer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
122 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,35 @@ | ||
#include <iostream> | ||
|
||
using std::cin; using std::cout; using std::endl; | ||
|
||
int main() | ||
{ | ||
unsigned aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0; | ||
char ch; | ||
while (cin >> ch) | ||
switch (ch) | ||
switch (tolower(ch)) | ||
{ | ||
case 'a': | ||
case 'A': | ||
++aCnt; | ||
break; | ||
case 'e': | ||
case 'E': | ||
++eCnt; | ||
break; | ||
case 'i': | ||
case 'I': | ||
++iCnt; | ||
break; | ||
case 'o': | ||
case 'O': | ||
++oCnt; | ||
break; | ||
case 'u': | ||
case 'U': | ||
++uCnt; | ||
break; | ||
} | ||
//another way to solve it | ||
/* while (cin >> ch) | ||
{ | ||
ch = tolower(ch); | ||
switch (ch) | ||
{ | ||
case 'a': | ||
++aCnt; | ||
break; | ||
case 'e': | ||
++eCnt; | ||
break; | ||
case 'i': | ||
++iCnt; | ||
break; | ||
case 'o': | ||
++oCnt; | ||
break; | ||
case 'u': | ||
++uCnt; | ||
break; | ||
} | ||
} | ||
*/ | ||
|
||
cout << "Number of vowel a(A): \t" << aCnt << '\n' | ||
<< "Number of vowel e(E): \t" << eCnt << '\n' | ||
<< "Number of vowel i(I): \t" << iCnt << '\n' | ||
<< "Number of vowel o(O): \t" << oCnt << '\n' | ||
<< "Number of vowel u(U): \t" << uCnt << endl; | ||
<< "Number of vowel e(E): \t" << eCnt << '\n' | ||
<< "Number of vowel i(I): \t" << iCnt << '\n' | ||
<< "Number of vowel o(O): \t" << oCnt << '\n' | ||
<< "Number of vowel u(U): \t" << uCnt << endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.