1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void calculateVowels(string text, int a_vowel, int e_vowel, int i_vowel, int o_vowel, int u_vowel)
{
int a(0), e(0), i(0), o(0), u(0);
for (int c = 1; c <= text.size(); c++)
{
if (text[c] == 'a')
{a++;}
else if (text[c] == 'e')
{e++;}
else if (text[c] == 'i')
{i++;}
else if (text[c] == 'o')
{o++;}
else if (text[c] == 'u')
{u++;}
}
a_vowel = a, e_vowel = e, i_vowel = i, o_vowel = o, u_vowel = u;
}
int main()
{
string text;
cout << "Enter some text:" << endl;
getline(cin, text);
int a(0), e(0), i(0), o(0), u(0), non_space_characters;
calculateVowels(text, a, e, i , o , u);
cout << text << " " << a << " " << e << " " << i << " " << o << " " << u << endl;
cout << "A:" << setfill('*') << setw(a) << endl;
cout << "E:" << setfill('*') << setw(e) << endl;
cout << "I:" << setfill('*') << setw(i) << endl;
cout << "O:" << setfill('*') << setw(o) << endl;
cout << "U:" << setfill('*') << setw(u) << endl;
system("PAUSE");
return 0;
}
|