fork download
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <array>
  4.  
  5. //using namespace std; <-- don't do this.
  6.  
  7. int main(){
  8. std::array<std::string, 10> sentence; // ten strings
  9.  
  10. // populate the array of sentences.
  11. for (size_t i = 0; i < sentence.size(); ++i) { // use ++ when ++ is what you mean.
  12. std::cin >> sentence[i];
  13. }
  14.  
  15. for (size_t i = 0; i < sentence.size(); ++i) {
  16. size_t f = rand() % sentence.size(); // returns a value 0-9
  17. std::cout << sentence[f] << " ";
  18. }
  19. std::cout << std::endl;
  20. }
  21.  
Success #stdin #stdout 0s 3476KB
stdin
hello
world
pizza
is
ready
walk
the
dog
good
bye
stdout
is the dog walk is walk the pizza bye world