Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cctype>
- #include <vector>
- #include <stdio.h>
- #include <string.h>
- using namespace std;
- int main()
- {
- string line;
- vector <int> LetterData(1000);
- cout << "Enter your text" << "\n";
- getline(cin, line);
- for (int i=0 ; i<line.size(); ++i) {
- if(isalpha(line[i])) {
- LetterData[int(tolower(line[i]))]
- += 1;
- }
- }
- for (int i = 97; i < 123; ++i){
- char ch= i;
- double Rates (100.0 * LetterData[i]/ strlen (string));
- cout << ch << "; " << LetterData[i]<< Rates<< "%" "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment