Advertisement
Krefeld187

Untitled

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