Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <cstring>
- using namespace std;
- int main()
- {
- string str = "this is one test string!";
- char bukvi[] = { 'e','t','i','o' };
- int sz = str.size();
- for (int i = 0; i < 4; i++) {
- int cnt = 0, max = 0, temp = 0;
- for (int j = 0; j < sz; j++) {
- if (str[j] == bukvi[i]) {
- cnt++;
- }
- }
- if (max < cnt) {
- temp = max;
- max = cnt;
- cnt = 0;
- if (max > temp) {
- cout << bukvi[i] << " is the most common letter. It is repeated " << max << " times.\n";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement