Glenpl

Untitled

Nov 5th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. //////////////////////////////////////////
  7. string haslo;
  8. string bufor = "";
  9. char a,b,c,d,e;
  10.  
  11. //////////////////////////////////////////
  12. void znak1();
  13. void znak2();
  14. void znak3();
  15. void znak4();
  16. void znak5();
  17.  
  18. //////////////////////////////////////////
  19. int main()
  20. {
  21.     cout << "Podaj haslo (max 5 znaki): ";
  22.     cin >> haslo;
  23.  
  24.     int dlugosc = haslo.length();
  25.  
  26.     if (dlugosc == 1)
  27.     {
  28.         znak1();
  29.     }
  30.  
  31.     else if (dlugosc == 2)
  32.     {
  33.         znak2();
  34.     }
  35.     else if (dlugosc == 3)
  36.     {
  37.         znak3();
  38.     }
  39.     else if (dlugosc == 4)
  40.     {
  41.         znak4();
  42.     }
  43.     else if (dlugosc == 5)
  44.     {
  45.         znak5();
  46.     }
  47.     else
  48.     {
  49.         cout << "Bledna dlugosc hasla!";
  50.     }
  51.     return 0;
  52.  
  53. }
  54.  
  55. //////////////////////////////////////////
  56. void znak1()
  57. {
  58.     for(int i = 32; i <= 127; i++)
  59.     {
  60.         a = i;
  61.         bufor = a;
  62.         if(bufor == haslo)
  63.         {
  64.             cout << "Mam! Twoje haslo to: " << bufor;
  65.             return;
  66.         }
  67.     }
  68. }
  69.  
  70. //////////////////////////////////////////
  71. void znak2()
  72. {
  73.     for(int j = 32; j <= 127; j++)
  74.     {
  75.         for(int i = 32; i <= 127; i++)
  76.         {
  77.             a = i;
  78.             b = j;
  79.             bufor = "";
  80.             bufor += b;
  81.             bufor += a;
  82.             if(bufor == haslo)
  83.             {
  84.                 cout << "Mam! Twoje haslo to: " << bufor;
  85.                 return;
  86.             }
  87.         }
  88.     }
  89. }
  90.  
  91. /////////////////////////////////////////
  92. void znak3()
  93. {
  94.     for(int k = 32; k <= 127; k++)
  95.     {
  96.         for(int j = 32; j <= 127; j++)
  97.         {
  98.             for(int i = 32; i <= 127; i++)
  99.             {
  100.                 a = i;
  101.                 b = j;
  102.                 c = k;
  103.                 bufor = "";
  104.                 bufor += c;
  105.                 bufor += b;
  106.                 bufor += a;
  107.                 if(bufor == haslo)
  108.                 {
  109.                     cout << "Mam! Twoje haslo to: " << bufor;
  110.                     return;
  111.                 }
  112.             }
  113.         }
  114.     }
  115. }
  116.  
  117. ////////////////////////////////////////
  118. void znak4()
  119. {
  120.     for(int l = 32; l <= 127; l++)
  121.     {
  122.         for(int k = 32; k <= 127; k++)
  123.         {
  124.             for(int j = 32; j <= 127; j++)
  125.             {
  126.                 for(int i = 32; i <= 127; i++)
  127.                 {
  128.                     a = i;
  129.                     b = j;
  130.                     c = k;
  131.                     d = l;
  132.                     bufor = "";
  133.                     bufor += d;
  134.                     bufor += c;
  135.                     bufor += b;
  136.                     bufor += a;
  137.                     if(bufor == haslo)
  138.                     {
  139.                         cout << "Mam! Twoje haslo to: " << bufor;
  140.                         return;
  141.                     }
  142.                 }
  143.             }
  144.         }
  145.     }
  146. }
  147.  
  148. ////////////////////////////////////////
  149. void znak5()
  150. {
  151.     for(int m = 32; m <= 127; m++)
  152.     {
  153.         for(int l = 32; l <= 127; l++)
  154.         {
  155.             for(int k = 32; k <= 127; k++)
  156.             {
  157.                 for(int j = 32; j <= 127; j++)
  158.                 {
  159.                     for(int i = 32; i <= 127; i++)
  160.                     {
  161.                         a = i;
  162.                         b = j;
  163.                         c = k;
  164.                         d = l;
  165.                         e = m;
  166.                         bufor = "";
  167.                         bufor += e;
  168.                         bufor += d;
  169.                         bufor += c;
  170.                         bufor += b;
  171.                         bufor += a;
  172.                         if(bufor == haslo)
  173.                         {
  174.                             cout << "Mam! Twoje haslo to: " << bufor;
  175.                             return;
  176.                         }
  177.                     }
  178.                 }
  179.             }
  180.         }
  181.     }
  182. }
Advertisement
Add Comment
Please, Sign In to add comment