Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <algorithm>
- #include <fstream>
- #include <string>
- using namespace std;
- string unique_elements(string s) {
- string res;
- for (size_t i = 0; i < s.size(); i++)
- {
- if (res.find(s[i]) == string::npos) {
- res += s[i];
- }
- }
- sort(begin(res), end(res));
- return res;
- }
- int main() {
- ifstream input("\\\\lit.msu.ru\\Storage\\Students\\!Common\\11 класс ИНФОРМАТИКА\\Файлы для диагностической работы 31.03.2021 ЕГЭ информатика\\24\\24.txt");
- string s, minstr;
- int now = 0, min = INT_MAX;
- while (getline(input, s)) {
- now = count(begin(s), end(s), 'G');
- if (now < min) {
- min = now;
- minstr = s;
- }
- }
- string un = unique_elements(minstr);
- int max = 0;
- char maxch;
- for (size_t i = 0; i < un.size(); i++)
- {
- if (count(begin(minstr), end(minstr), un[i]) >= max) {
- max = count(begin(minstr), end(minstr), un[i]);
- maxch = un[i];
- }
- }
- cout << maxch;
- return 0;
- }
Add Comment
Please, Sign In to add comment