fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <array>
  4. #include <random>
  5. #include <algorithm>
  6.  
  7. int main()
  8. {
  9. std::array<std::string, 3> quotes = {
  10. "1 hello", "2 world", "3 hello world"
  11. };
  12.  
  13. std::random_device rd;
  14. std::mt19937 gen(rd());
  15. std::uniform_int_distribution<> quoteSeed(0, quotes.size() - 1);
  16.  
  17. int quoteNo = quoteSeed(gen);
  18. auto quote = quotes[quoteNo];
  19. std::shuffle(quote.begin(), quote.end(), gen);
  20. std::cout << quote << "\n";
  21. }
  22.  
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
oe lhl1