fork(1) download
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4.  
  5. class NameGen{
  6. private:
  7. int rnd_sml, rnd_cap;
  8. char arr[6];
  9. const char* alphab[4] ={
  10. {"AEIOUY"},
  11. {"BCDFGHJKLMNPQRSTVWXZ"},
  12. {"aeiouy"},
  13. {"bcdfghjklmnpqrstvwxz"}
  14. };
  15.  
  16. public:
  17. string genName()
  18. {
  19. srand(time(0));
  20. for(int i=0; i< rand() % 6 + 2; ++i){
  21. rnd_sml = rand() % 3 + 2;
  22. rnd_cap = rand() % 2;
  23. arr[i] = alphab[(i==0) ? rnd_cap : rnd_sml]
  24. [(i==0) ? ((rnd_cap==0) ? rand() % 6 : rand() % 20) : ((rnd_sml==2) ? rand() % 6 : rand() % 20)];
  25. }
  26. return arr;
  27. }
  28. }alph;
  29.  
  30. int main()
  31. {
  32. cout << alph.genName()<< endl;
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
Elca