Advertisement
Krefeld187

Untitled

Jan 19th, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4. #include <cstring>
  5. #include <cstdio>
  6. using namespace std;
  7.  
  8. auto zum(string verschalp, int wahl, string dat) -> string
  9. {
  10. //string scry = "";
  11. string rA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  12. string cA = verschalp;
  13. int choice;
  14. choice = wahl;
  15. string s;
  16. s = dat;
  17. int max = s.size();
  18. if (choice == 1)
  19. {
  20. for (int i = 0; i < max; i++)
  21. {
  22. for (int z = 0; z < 26; ++z)
  23. {
  24. if (s[i] == rA[z])
  25. {
  26. dat[i] = cA[z];
  27. }
  28. }
  29. }
  30. }
  31. else
  32. if (choice == 2)
  33. {
  34. for (int i = 0; i < max; ++i)
  35. {
  36. for (int z = 0; z < 26; ++z)
  37. {
  38. if (s[i] == cA[z])
  39. dat[i] = rA[z];
  40. }
  41. }
  42. }
  43. return dat;
  44. }
  45.  
  46. int main()
  47. {
  48. string key = "GKXCSLZUAHWDBMTYENJVPOIRFQ";
  49. string ver = "HALLOASTERIX";
  50. cout << "a)" << endl;
  51. cout << "Klartext : " << ver << endl << "Geheimtext : " << zum(key, 1, ver) <<endl;
  52. ver = "JGDOSXGSJGN";
  53. cout << "b)" << endl;
  54. cout << "Klartext : " << ver << endl << "Geheimtext : " << zum(key, 2, ver) << endl;
  55. string s = " ";
  56. cout << (int)s[0] << endl;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement