Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <iostream>
- #include <math.h>
- #include <conio.h>
- using namespace std;
- void Generuj(string& haslo);
- void Wprowadz(string haslo);
- int main()
- {
- int Wybor=1;
- string haslo = "";
- while(Wybor == 1 || Wybor ==2 )
- {
- cout << "MENU" << endl;
- cout << "1 - Generuj haslo" << endl;
- cout << "2 - Wprowadz haslo" << endl;
- cout << "Donowlny znak aby zakonczyc" << endl;
- cout << endl;
- cout << "Twoj wybor: ";
- cin >> Wybor; system("cls");
- switch (Wybor)
- {
- case 1:
- Generuj(haslo); break;
- case 2:
- Wprowadz(haslo); break;
- default: cout << "Koniec programu."; break;
- }
- }
- system("pause");
- }
- void Generuj(string& haslo)
- {
- string wybor2 = "tak";
- while (wybor2 == "tak")
- {
- int n;
- cout << "Ile znakow ma miec twoje haslo? ";
- cin >> n;
- string haslo = "";
- srand(time(NULL));
- for (int i = 0; i < n; i++)
- {
- char a = rand() % 94 + 33;
- haslo += a;
- }
- cout << haslo << endl;
- cout << "Czy chcesz wygenerowac nowe haslo?" << endl;
- cout << "wprowadz tak lub nie: ";
- cin >> wybor2;
- }
- }
- void Wprowadz(string haslo)
- {
- cout << haslo;
- string wybor3 = "tak";
- while (wybor3 == "tak")
- {
- cout << haslo;
- cout << "Wprowadz wygenerowane haslo: ";
- string haslo1 = "";
- char c = ' ';
- while (c != 13) //Petla az enter zostanie wcisniety
- {
- c = _getch();
- if(c!=13)
- haslo1 += c;
- cout << "*";
- }
- cout << endl << haslo1 << endl; //
- cout << "Wprowadz ponownie wygenerowane haslo: ";
- string haslo2 = "";
- char b = ' ';
- while (b != 13)
- {
- b = _getch();
- if (b != 13)
- {
- haslo2 += b;
- //cout << "*";
- }
- }
- cout << endl << haslo2 << endl; //
- if ((haslo1 == haslo) && (haslo2 == haslo)) cout << "Prawidlowo wpisales haslo! :)";
- else cout << "Nieprawidlowo wpisales haslo! :(" << endl;
- cout << "haslo = " << haslo << " lenght = " << haslo.length() << endl;
- cout << "haslo1 = " << haslo1 << " lenght = " << haslo1.length() << endl;
- cout << "haslo2 = " << haslo2 << " lenght = " << haslo2.length() << endl;
- cout << "Czy chcesz sprobowac jeszcze raz? " << endl;
- cout << "wprowadz tak lub nie: ";
- cin >> wybor3;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement