Facebook
From Putrid Parrot, 7 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 244
  1. #include<iostream>
  2. #include<string>
  3. #include<ctime>
  4. #include<cstdlib>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.         string odp;
  10.         do{
  11.                 srand(time(NULL));
  12.                 string sa[6]={"a","e","u","y","i","o"};
  13.                 string
  14.                 sp[20]= {"q","w","r","t","p","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"};
  15.                 string zn[9]={"!","@","#","$","%","^","&","*","?"};
  16.                 string cy[10]={"1","2","3","4","5","6","7","8","9","0"};
  17.                 string haslo;
  18.                 int n;
  19.                 cout<<"Z ilu znakow ma skladac sie haslo?"<<endl;
  20.                 cin>>n;
  21.                 for (int i=1; i<=n; i++)
  22.                 {if (i==n)
  23.                 haslo = haslo+zn[rand()%9];
  24.                 else
  25.                 if(i==n-1)
  26.                 haslo=haslo+cy[rand()%10];
  27.                 else
  28.                 if(i%2==0)
  29.                 haslo=haslo+sa[rand()%6];
  30.                 else
  31.                 if(i%2!=0)
  32.                 haslo=haslo+sp[rand()%20];
  33.                
  34.                 }
  35. haslo[0]=toupper(haslo[0]);
  36. cout<<haslo<<endl;
  37. cout<<"Czy generowac jeszcze raz? (tak/nie)"<<endl;
  38. cin>>odp;
  39. cout<<endl;
  40.  
  41. for (int i=1; i<=odp.length();i++)
  42. odp[i-1]=tolower(odp[i-1]);
  43.                
  44.                
  45.         }
  46. while(odp=="tak");
  47.  
  48. return 0;
  49. }