fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <random>
  5. #include <string>
  6. using namespace std;
  7.  
  8. int main() {
  9.  
  10. const vector<string> days = { "pn", "wt", "sr", "czw", "pt" };
  11. const int nums_per_day = 5;
  12. const int elements_num = days.size() * nums_per_day;
  13.  
  14. vector<int> nums(elements_num);
  15. iota(begin(nums), end(nums), 0);
  16. shuffle(begin(nums), end(nums), std::mt19937{std::random_device{}()});
  17.  
  18. for(auto it = begin(nums); it != end(nums); advance(it, nums_per_day)) {
  19. cout << days[distance(begin(nums), it)/nums_per_day] << ": ";
  20. for_each(it, it+nums_per_day, [](auto num) {
  21. cout << num << " ";
  22. });
  23. cout << endl;
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
pn: 20 0 18 11 23 
wt: 10 13 8 15 21 
sr: 19 7 6 5 17 
czw: 12 16 3 24 2 
pt: 4 22 9 1 14