Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <string.h>
- #include <fstream>
- #include <iostream>
- #include <cmath>
- #include <limits>
- #include <iomanip>
- #include <list>
- #include <string>
- #include <cstring>
- using namespace std;
- int main()
- {
- char mess[1000];
- char messb[1000];
- char alpha[] = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
- char alphaB[] = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЫЭЮЯ";
- int count[33][33] = { 0 };
- int totalcount = 0;
- char assist[] = " .,-:;^123456789!?";
- int alphabeg = strlen(alpha);
- char codealpha[100];
- char codealphaB[100];
- system("chcp 1251");
- system("cls");
- int zeronumb;
- int n = 4, k = 4;
- int nr;
- int target = 0;
- ofstream fout("end.txt");
- ifstream start("start.txt");
- string buf;
- while (!start.eof())
- {
- getline(start,buf);
- }
- int messtagret = 0;
- for (int i = 0; i < buf.length() - 1; ++i)
- {
- int check = 0;
- for (int j = 0; j < alphabeg; ++j)
- {
- if ((buf[i] == alpha[j]) || (buf[i] == alphaB[j]))
- {
- for (int k = 0; k < alphabeg; ++k)
- {
- if ((buf[i+1] == alpha[k]) || (buf[i+1] == alphaB[k]))
- {
- count[j][k]++;
- totalcount++;
- break;
- }
- }
- }
- }
- }
- int length = target;
- if (alphabeg%n == 0) { cout << "Error, wrong A key"; }
- cout << "Сочетание" << "\t" << "Всего в тексте" << "\t" << "Относительная частота" << endl;;
- for (int i = 0; i < alphabeg; ++i)
- {
- for (int j = 0; j < alphabeg; ++j)
- {
- float oftency = (float)count[i][j] / totalcount;
- if (oftency > 0) {
- cout << alphaB[i] << alpha[j] << "\t" << count[i][j] << "\t" << setprecision(3) << oftency << "%" << endl;
- fout << alphaB[i] << alpha[j] << "\t" << count[i][j] << "\t" << setprecision(3) << oftency << "%" << endl;
- }
- }
- }
- system("pause");
- fout.close();
- return 0;
- }
Add Comment
Please, Sign In to add comment