Advertisement
lucks232

password gen

Apr 14th, 2022
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char password[8];
  9.  
  10.     srand(time(NULL));
  11.  
  12.     for (int i = 0; i < 8; i++)
  13.     {
  14.         int n = rand() % 3;
  15.  
  16.         if (n == 0)
  17.         {
  18.             int s = rand() % 10;
  19.             password[i] = '0' + s;
  20.         }
  21.  
  22.         if (n == 1)
  23.         {
  24.             int s = rand() % 26;
  25.             password[i] = 'a' + s;
  26.         }
  27.  
  28.         if (n == 2)
  29.         {
  30.             int s = rand() % 26;
  31.             password[i] = 'A' + s;
  32.         }
  33.         n = 0;
  34.     }
  35.  
  36.     cout << password << endl << "Quieres generar otra key? (Y or N)\n";
  37.     char a;
  38.     cin >> a;
  39.     if ((a == 'Y') || (a == 'y'))
  40.     {
  41.         cout << endl;
  42.         return(main());
  43.     }
  44.  
  45.     else
  46.     {
  47.         return(0);
  48.     }
  49.  
  50.     system("pause");
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement