Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //by steef
- #include <string>
- #include <iostream>
- using namespace std;
- string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- string alphabet_cript = "QWERTYUIOPASDFGHJKLZXCVBNM";
- void main()
- {
- string tmp;
- int val;
- cout << "voulez vous crypter(1) ou decrypter(2) ? " << endl;
- cin >> val;
- cin.get();
- if (val == 1)
- {
- cout << "Entrez la phrase a crypter :" << endl;
- getline(cin, tmp);
- for (int i = 0; i < tmp.size(); i++)
- {
- for (int j = 0; j < alphabet.size(); j++)
- if (tmp.at(i) == alphabet.at(j) || tmp.at(i) == alphabet.at(j)+32)
- {
- tmp.at(i) = alphabet_cript.at(j);
- break;
- }
- }
- cout << "le mot crypter :" << endl;
- cout << tmp << endl;
- }
- else if (val == 2)
- {
- cout << "Entrez la phrase a decrypter :" << endl;
- getline(cin, tmp);
- for (int i = 0; i < tmp.size(); i++)
- {
- for (int j = 0; j < alphabet.size(); j++)
- if (tmp.at(i) == alphabet_cript.at(j) || tmp.at(i) == alphabet_cript.at(j)+32)
- {
- tmp.at(i) = alphabet.at(j);
- break;
- }
- }
- cout << "le mot crypter :" << endl;
- cout << tmp << endl;
- }
- else
- cout << "Tu sais pas ecrire 1 ou 2 ??" << endl;
- cin.get();
- cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment