Glenpl

Untitled

Oct 23rd, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include "sprawdzacz.h"
  3. #include <time.h>
  4. #include <cstdlib>
  5. #include <conio.h>
  6.  
  7. using namespace std;
  8.  
  9. string generujhaslo(int dl)
  10. {
  11.     string haslo = "";
  12.     int znak;
  13.  
  14.     for (int i = 0; i < dl; i++)
  15.     {
  16.         znak = (rand()%93) + 32;
  17.         if (znak == 32)
  18.         {
  19.             i--;
  20.             continue;
  21.         }
  22.         haslo = (char)znak + haslo;
  23.     }
  24.  
  25.     return haslo;
  26. }
  27.  
  28. int main()
  29. {
  30.     sprawdzacz sp;
  31.     char ile[] = "10000000000";
  32.     int ile_cal;
  33.     srand(time(NULL));
  34.     cout << "                   GENERATOR LOSOWYCH HASEL" << endl << endl << endl;
  35.     cout << "Z ilu znakow ma skladac sie haslo?" << endl;
  36.     cout << "Ile: ";
  37.     cin >> ile;
  38.     if (sp.tylko_cyfry(ile) == false)
  39.     {
  40.         ile_cal = atoi(ile);
  41.         cout << endl << endl;
  42.         cout << "Haslo:   ";
  43.         cout << generujhaslo(ile_cal);
  44.     }
  45.     else
  46.     {
  47.         cout << "Bledna ilosc znakow!";
  48.     }
  49.     getch();
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment