Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1.  
  2. #include "pch.h"
  3. #include <iostream>
  4. #include <string>
  5. #include <cstring>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string str = "this is one test string!";
  11. char bukvi[] = { 'e','t','i','o' };
  12. int sz = str.size();
  13.  
  14.  
  15. for (int i = 0; i < 4; i++) {
  16. int cnt = 0, max = 0, temp = 0;
  17. for (int j = 0; j < sz; j++) {
  18. if (str[j] == bukvi[i]) {
  19.  
  20. cnt++;
  21. }
  22. }
  23. if (max < cnt) {
  24. temp = max;
  25. max = cnt;
  26. cnt = 0;
  27. if (max > temp) {
  28. cout << bukvi[i] << " is the most common letter. It is repeated " << max << " times.\n";
  29. }
  30. }
  31.  
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement