Steefmaester

Crypt / Dé-Crypt Spass

Jul 27th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. //by steef
  2. #include <string>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. string alphabet =       "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  8. string alphabet_cript = "QWERTYUIOPASDFGHJKLZXCVBNM";
  9.  
  10.  
  11.  
  12. void main()
  13. {
  14.     string tmp;
  15.     int val;
  16.     cout << "voulez vous crypter(1) ou decrypter(2) ? " << endl;
  17.     cin >> val;
  18.     cin.get();
  19.  
  20.     if (val == 1)
  21.     {
  22.         cout << "Entrez la phrase a crypter :" << endl;
  23.  
  24.         getline(cin, tmp);
  25.  
  26.         for (int i = 0; i < tmp.size(); i++)
  27.         {
  28.  
  29.             for (int j = 0; j < alphabet.size(); j++)
  30.  
  31.                 if (tmp.at(i) == alphabet.at(j) || tmp.at(i) == alphabet.at(j)+32)
  32.                 {
  33.                     tmp.at(i) = alphabet_cript.at(j);
  34.                     break;
  35.                 }
  36.         }
  37.  
  38.  
  39.         cout << "le mot crypter :" << endl;
  40.         cout << tmp << endl;
  41.  
  42.  
  43.     }
  44.     else if (val == 2)
  45.     {
  46.         cout << "Entrez la phrase a decrypter :" << endl;
  47.  
  48.         getline(cin, tmp);
  49.  
  50.         for (int i = 0; i < tmp.size(); i++)
  51.         {
  52.  
  53.             for (int j = 0; j < alphabet.size(); j++)
  54.  
  55.                 if (tmp.at(i) == alphabet_cript.at(j) || tmp.at(i) == alphabet_cript.at(j)+32)
  56.                 {
  57.                     tmp.at(i) = alphabet.at(j);
  58.                     break;
  59.                 }
  60.         }
  61.  
  62.  
  63.         cout << "le mot crypter :" << endl;
  64.         cout << tmp << endl;
  65.  
  66.  
  67.  
  68.     }
  69.     else
  70.         cout << "Tu sais pas ecrire 1 ou 2 ??" << endl;
  71.  
  72.  
  73.     cin.get(); 
  74.     cin.get();
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment