fork(1) download
  1. #include <cstdlib>
  2. #include <ctime>
  3. #include <vector>
  4. #include <string>
  5. #include <algorithm>
  6. #include <iostream>
  7.  
  8. int main()
  9. {
  10. std::srand( std::time(nullptr) ) ;
  11.  
  12. std::vector<std::string> seq { "Knocturne", "LB", "Manga", "JLBorges", "abc",
  13. "def", "ghi", "jkl", "mno", "pqr", "stu" } ;
  14.  
  15. std::random_shuffle( std::begin(seq), std::end(seq) ) ;
  16.  
  17. for( std::size_t i = 0 ; i < seq.size() - 1 ; i += 2 )
  18. std::cout << "pair " << seq[i] << " with " << seq[i+1] << '\n' ;
  19. }
  20.  
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
pair Manga with LB
pair jkl with stu
pair mno with Knocturne
pair JLBorges with ghi
pair def with pqr