fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <ctime>
  5.  
  6. using namespace std;
  7.  
  8. int random(unsigned limit)
  9. {
  10. return rand() % limit;
  11. }
  12.  
  13. string getRandom(string s[], unsigned size)
  14. {
  15. return s[random(size)];
  16. }
  17.  
  18. static string getWorldName(){
  19. string first[10] = { "Wicked", "Epic", "Blue", "Horrible", "Soft", "Lol", "Fallen", "Wild", "Calm", "Fierce" };
  20. string second[9] = { "Corn", "Horse", "Man", "Cheese", "Forest", "Shade", "Box", "Waterwheel", "Village" };
  21. string third[3] = { "Mountains", "Fields", "Shores" };
  22.  
  23. string world_name = getRandom(first, 10) + " " + getRandom(second, 9) + " " + getRandom(third, 3);
  24. return world_name;
  25. }
  26.  
  27. int main()
  28. {
  29. std::srand(time(0));
  30.  
  31. for (unsigned i = 0; i < 10; ++i)
  32. std::cout << getWorldName() << '\n';
  33. }
  34.  
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Epic Forest Mountains
Calm Box Shores
Soft Forest Fields
Lol Man Shores
Soft Forest Mountains
Fallen Cheese Fields
Lol Horse Fields
Blue Horse Shores
Soft Cheese Mountains
Fallen Forest Shores