Glenpl

Untitled

Nov 9th, 2014
304
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.     for (int i = 0; i < dl; i++)
  14.     {
  15.         znak = (rand()%93) + 32;
  16.         if (znak == 32)
  17.         {
  18.             i--;
  19.             continue;
  20.         }
  21.         haslo = (char)znak + haslo;
  22.     }
  23.     return haslo;
  24. }
  25.  
  26. int main()
  27. {
  28.     sprawdzacz sp;
  29.     char ile[] = "10000000000";
  30.     int ile_cal;
  31.     srand(time(NULL));
  32.     cout << "                   GENERATOR LOSOWYCH HASEL" << endl << endl << endl;
  33.     cout << "Z ilu znakow ma skladac sie haslo?" << endl;
  34.     cout << "Ile: ";
  35.     cin >> ile;
  36.     if (sp.tylko_cyfry(ile) == false)
  37.     {
  38.         ile_cal = atoi(ile);
  39.         cout << endl << endl;
  40.         cout << "Haslo:   ";
  41.         cout << generujhaslo(ile_cal);
  42.     }
  43.     else
  44.     {
  45.         cout << "Bledna ilosc znakow!";
  46.     }
  47.     getch();
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment