ademosh

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

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