Someguy384728

Code

Apr 22nd, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4. #include <vector>
  5. #include <stdio.h>
  6. #include <string.h>
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. string line;
  12. vector <int> LetterData(1000);
  13. cout << "Enter your text" << "\n";
  14. getline(cin, line);
  15.  
  16. for (int i=0 ; i<line.size(); ++i) {
  17. if(isalpha(line[i])) {
  18. LetterData[int(tolower(line[i]))]
  19.  
  20. += 1;
  21. }
  22. }
  23.  
  24. for (int i = 97; i < 123; ++i){
  25. char ch= i;
  26. double Rates (100.0 * LetterData[i]/ strlen (string));
  27. cout << ch << "; " << LetterData[i]<< Rates<< "%" "\n";
  28.  
  29.  
  30. }
  31.  
  32. return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment