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
|
#include <iostream>
#include <string>
using namespace std;
int main(){
char alp[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'w', 'y', 'z'};
int numbers[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
string input;
getline(cin, input);
int count = 0;
for (int i = 0; i < input.length(); i++)
{
switch(input.at(i))
{ case 'a': count = numbers[i++]; break;
case 'b': count = numbers[i++]; break;
case 'c': count = numbers[i++]; break;
//etc...
}
}
cout << "Letter | # Of Occurances" << endl;
for (int i = 0; i < 26; i++)
{
cout << alp[i] << " | " << count << endl;
}
}
|