Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdio>
- #include <vector>
- #include <string>
- #include <cctype>
- #include <iomanip>
- //#include <cmath>
- #include <iterator>
- #include <utility>
- #include <algorithm>
- #include <cstdlib>
- #include <math.h>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- ifstream in("input.txt");
- ofstream out("output.txt");
- unsigned char c;
- vector <vector <int> > vec(33, vector <int>(33, 0));
- int counter = 0;
- int last_f = -1, last_s = -1;
- bool flag = false;
- unsigned char first, second;
- while (!in.eof())
- {
- in >> c;
- c = tolower(c);
- if (((int) ((unsigned char) ('а')) <= (int)c && (int)c <= (int) ((unsigned char) ('я'))) || ((int) c == 184))
- {
- if (!flag)
- {
- second = c;
- flag = true;
- }
- else
- {
- first = second;
- second = c;
- int fcode = (int)first;
- int lcode = (int)second;
- if (fcode == 184)
- {
- if (lcode == 184)
- {
- vec[0][0]++;
- last_f = 0;
- last_s = 0;
- }
- else
- {
- lcode -= 223;
- vec[0][lcode]++;
- last_f = 0;
- last_s = lcode;
- }
- }
- else
- {
- fcode -= 223;
- if (lcode == 184)
- {
- vec[fcode][0]++;
- last_f = fcode;
- last_s = 0;
- }
- else
- {
- lcode -= 223;
- vec[fcode][lcode]++;
- last_f = fcode;
- last_s = lcode;
- }
- }
- counter++;
- }
- }
- else
- flag = false;
- }
- if (last_f != -1)
- vec[last_f][last_s]--;
- int count_f = 0;
- int count_s = 0;
- flag = false;
- vector < pair <double, string> > SortResult;
- double Result;
- string temp;
- for(int i = 1; i < 33; i++) {
- for(int j = 1; j < 33; j++) {
- if(count_f == 6) {
- flag = true;
- if(count_s == 6) {
- Result = (((double)vec[0][0] / counter) * 1000) / 1000;
- temp = (unsigned char)(184);
- temp += (unsigned char)(184);
- SortResult.push_back(make_pair(Result, temp));
- j--;
- }
- else {
- Result = (((double)vec[0][j] / counter) * 1000) / 1000;
- temp = (unsigned char)(184);
- temp += (unsigned char)(j + 223);
- SortResult.push_back(make_pair(Result, temp));
- }
- count_s++;
- }
- else {
- if(count_s == 6) {
- Result = (((double)vec[i][0] / counter) * 1000) / 1000;
- temp = (unsigned char)(i + 223);
- temp += (unsigned char)(184);
- SortResult.push_back(make_pair(Result, temp));
- }
- else {
- Result = (((double)vec[i][j] / counter) * 1000) / 1000;
- temp = (unsigned char)(i + 223);
- temp += (unsigned char)(j + 223);
- SortResult.push_back(make_pair(Result, temp));
- }
- count_s++;
- }
- }
- if (flag) {
- i--;
- flag = false;
- }
- count_f++;
- count_s = 0;
- }
- sort(SortResult.begin(), SortResult.end());
- for(int i = (int) SortResult.size() - 1; i >= 0; i--) {
- if(SortResult[i].first != 0) {
- out << SortResult[i].second << " = " << fixed << setprecision(3) << SortResult[i].first << endl;
- cout << SortResult[i].second << " = " << fixed << setprecision(3) << SortResult[i].first << endl;
- }
- }
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement