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>
- using namespace std;
- int main()
- {
- char mess[1000];
- char messb[1000];
- char alpha[] = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
- char alphaB[] = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЫЭЮЯ";
- int count[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");
- while (!start.eof())
- {
- char buf;
- start.get(messb[target]);
- target++;
- }
- for (int i = 0; i < target - 1; ++i)
- {
- mess[i] = messb[i];
- }
- for (int i = 0; i < target - 1; ++i)
- {
- for (int j = 0; j < alphabeg; ++j)
- {
- if ((mess[i] == alpha[j]) || (mess[i] == alphaB[j]))
- {
- count[j]++;
- totalcount++;
- }
- }
- }
- int length = target;
- if (alphabeg%n == 0) { cout << "Error, wrong A key"; }
- cout << "Буква" << "\t" << "Всего в тексте" << "\t" << "Относительная частота" << endl;;
- for (int i = 0; i < alphabeg; ++i)
- {
- float oftency = (float)count[i] / totalcount;
- cout << alphaB[i] << "\t" << count[i] << "\t" << setprecision(3)<< oftency << "%"<<endl;
- fout << alphaB[i] << "\t" << count[i] << "\t" << setprecision(3) << oftency << "%" << endl;
- }
- system("pause");
- fout.close();
- return 0;
- }
Add Comment
Please, Sign In to add comment