Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cctype>
- #include <cstring>
- #include <cstdio>
- using namespace std;
- auto zum(string verschalp, int wahl, string dat) -> string
- {
- string rA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- string cA = verschalp;
- int choice;
- choice = wahl;
- string s;
- s = dat;
- int max = s.size();
- if (choice == 1)
- {
- for (int i = 0; i < max; i++)
- {
- for (int z = 0; z < 26; ++z)
- {
- if (s[i] == rA[z])
- {
- dat[i] = cA[z];
- }
- }
- }
- }
- else
- if (choice == 2)
- {
- for (int i = 0; i < max; ++i)
- {
- for (int z = 0; z < 26; ++z)
- {
- if (s[i] == cA[z])
- dat[i] = rA[z];
- }
- }
- }
- return dat;
- }
- int main()
- {
- string key = "GKXCSLZUAHWDBMTYENJVPOIRFQ";
- string ver = "HALLOASTERIX";
- cout << "a)" << endl;
- cout << "Klartext : " << ver << endl << "Geheimtext : " << zum(key, 1, ver) <<endl;
- ver = "JGDOSXGSJGN";
- cout << "b)" << endl;
- cout << "Klartext : " << ver << endl << "Geheimtext : " << zum(key, 2, ver) << endl;
- string s = " ";
- cout << (int)s[0] << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement