Advertisement
Touch_Grass

Untitled

May 18th, 2023
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <random>
  3. #include <vector>
  4. #include <Windows.h>
  5.  
  6. std::vector<std::string> list {"h", "e", "l", "o", "w", "r", "d", " ","i"};
  7.  
  8. int getRandomInt(int minRange, int maxRange) {
  9.     std::random_device rd;
  10.     std::mt19937 gen(rd());
  11.  
  12.     std::uniform_int_distribution<int> distribution(minRange, maxRange);
  13.  
  14.     return distribution(gen);
  15. }
  16.  
  17. int main() {
  18.     std::string ans = "";
  19.     while (ans != "hello world") {
  20.         ans = "";
  21.         for (int i = 0; i < 11; i++) {
  22.             ans += list[getRandomInt(0, list.size() - 1)];
  23.         }
  24.         std::cout << ans << "\n";//for funny even though logging it is not really necessary and may affect performance
  25.     }
  26.     std::cout << ans << "\n";
  27.     Beep(1000, 2000);
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement