Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- //////////////////////////////////////////
- string haslo;
- string bufor = "";
- char a,b,c;
- //////////////////////////////////////////
- void znak1();
- void znak2();
- void znak3();
- //////////////////////////////////////////
- int main()
- {
- cout << "Podaj haslo (max 3 znaki): ";
- cin >> haslo;
- int dlugosc = haslo.length();
- if (dlugosc == 1)
- {
- znak1();
- }
- if (dlugosc == 2)
- {
- znak2();
- }
- if (dlugosc == 3)
- {
- znak3();
- }
- else
- {
- cout << "Bledna dlugosc hasla!";
- }
- return 0;
- }
- //////////////////////////////////////////
- void znak1()
- {
- for(int i = 31; i <= 127; i++)
- {
- a = i;
- bufor = a;
- if(bufor == haslo)
- {
- cout << "Mam! Twoje haslo to: " << bufor;
- break;
- }
- }
- }
- //////////////////////////////////////////
- void znak2()
- {
- for(int j = 31; j <= 127; j++)
- {
- for(int i = 31; i <= 127; i++)
- {
- a = i;
- b = j;
- bufor = b + a;
- if(bufor == haslo)
- {
- cout << "Mam! Twoje haslo to: " << bufor;
- break;
- }
- }
- }
- }
- /////////////////////////////////////////
- void znak3()
- {
- for(int k = 31; k <= 127; k++)
- {
- for(int j = 31; j <= 127; j++)
- {
- for(int i = 31; i <= 127; i++)
- {
- a = i;
- b = j;
- c = k;
- bufor = c + b + a;
- if(bufor == haslo)
- {
- cout << "Mam! Twoje haslo to: " << bufor;
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment