Glenpl

Untitled

Nov 4th, 2014
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. //////////////////////////////////////////
  7. string haslo;
  8. string bufor = "";
  9. char a,b,c;
  10.  
  11. //////////////////////////////////////////
  12. void znak1();
  13. void znak2();
  14. void znak3();
  15.  
  16. //////////////////////////////////////////
  17. int main()
  18. {
  19.     cout << "Podaj haslo (max 3 znaki): ";
  20.     cin >> haslo;
  21.  
  22.    int dlugosc = haslo.length();
  23.  
  24. if (dlugosc == 1)
  25. {
  26.     znak1();
  27. }
  28.  
  29. if (dlugosc == 2)
  30. {
  31.     znak2();
  32. }
  33. if (dlugosc == 3)
  34. {
  35.     znak3();
  36. }
  37. else
  38. {
  39. cout << "Bledna dlugosc hasla!";
  40. }
  41. return 0;
  42.  
  43. }
  44.  
  45. //////////////////////////////////////////
  46. void znak1()
  47. {
  48.     for(int i = 31; i <= 127; i++)
  49.     {
  50.         a = i;
  51.         bufor = a;
  52.         if(bufor == haslo)
  53.         {
  54.             cout << "Mam! Twoje haslo to: " << bufor;
  55.             break;
  56.         }
  57.     }
  58. }
  59.  
  60. //////////////////////////////////////////
  61. void znak2()
  62. {
  63.     for(int j = 31; j <= 127; j++)
  64.     {
  65.         for(int i = 31; i <= 127; i++)
  66.         {
  67.             a = i;
  68.             b = j;
  69.             bufor = b + a;
  70.             if(bufor == haslo)
  71.             {
  72.                 cout << "Mam! Twoje haslo to: " << bufor;
  73.                 break;
  74.             }
  75.         }
  76.     }
  77. }
  78.  
  79. /////////////////////////////////////////
  80. void znak3()
  81. {
  82.     for(int k = 31; k <= 127; k++)
  83.     {
  84.         for(int j = 31; j <= 127; j++)
  85.         {
  86.             for(int i = 31; i <= 127; i++)
  87.             {
  88.                 a = i;
  89.                 b = j;
  90.                 c = k;
  91.                 bufor = c + b + a;
  92.                 if(bufor == haslo)
  93.                 {
  94.                     cout << "Mam! Twoje haslo to: " << bufor;
  95.                     break;
  96.                 }
  97.             }
  98.         }
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment