ademosh

2 безопасность 2к19

Oct 21st, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include "pch.h"
  2. #include <string.h>
  3. #include <fstream>
  4. #include <iostream>
  5. #include <cmath>
  6. #include <limits>
  7. #include <iomanip>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. char mess[1000];
  14. char messb[1000];
  15. char alpha[] = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
  16. char alphaB[] = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЫЭЮЯ";
  17. int count[33] = { 0 };
  18. int totalcount = 0;
  19. char assist[] = " .,-:;^123456789!?";
  20. int alphabeg = strlen(alpha);
  21. char codealpha[100];
  22. char codealphaB[100];
  23. system("chcp 1251");
  24. system("cls");
  25. int zeronumb;
  26. int n = 4, k = 4;
  27. int nr;
  28. int target = 0;
  29. ofstream fout("end.txt");
  30. ifstream start("start.txt");
  31. while (!start.eof())
  32. {
  33. char buf;
  34. start.get(messb[target]);
  35. target++;
  36.  
  37. }
  38. for (int i = 0; i < target - 1; ++i)
  39. {
  40. mess[i] = messb[i];
  41. }
  42. for (int i = 0; i < target - 1; ++i)
  43. {
  44. for (int j = 0; j < alphabeg; ++j)
  45. {
  46. if ((mess[i] == alpha[j]) || (mess[i] == alphaB[j]))
  47. {
  48. count[j]++;
  49. totalcount++;
  50. }
  51. }
  52. }
  53. int length = target;
  54. if (alphabeg%n == 0) { cout << "Error, wrong A key"; }
  55. cout << "Буква" << "\t" << "Всего в тексте" << "\t" << "Относительная частота" << endl;;
  56. for (int i = 0; i < alphabeg; ++i)
  57. {
  58. float oftency = (float)count[i] / totalcount;
  59. cout << alphaB[i] << "\t" << count[i] << "\t" << setprecision(3)<< oftency << "%"<<endl;
  60. fout << alphaB[i] << "\t" << count[i] << "\t" << setprecision(3) << oftency << "%" << endl;
  61. }
  62. system("pause");
  63. fout.close();
  64. return 0;
  65. }
Add Comment
Please, Sign In to add comment