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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#include <algorithm>
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
string myString;
std::cout << "Please enter your string: " << endl;
getline (cin,myString);
std::cout << "Output: "<< endl
<< "a"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'a') << endl
<< "b"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'b') << endl
<< "c"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'c') << endl
<< "d"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'd') << endl
<< "e"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'e') << endl
<< "f"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'f') << endl
<< "g"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'g') << endl
<< "h"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'h') << endl
<< "i"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'i') << endl
<< "j"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'j') << endl
<< "k"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'k') << endl
<< "l"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'l') << endl
<< "m"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'm') << endl
<< "n"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'n') << endl
<< "o"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'o') << endl
<< "p"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'p') << endl
<< "q"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'q') << endl
<< "r"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'r') << endl
<< "s"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 's') << endl
<< "t"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 't') << endl
<< "u"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'u') << endl
<< "v"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'v') << endl
<< "w"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'w') << endl
<< "x"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'x') << endl
<< "y"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'y') << endl
<< "z"
<< setw(5)
<< std::count(myString.begin(), myString.end(), 'z') << endl;
return 0;
}
|