fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. int main() {
  6. const int MAX_INPUT = 10;
  7. const int INPUT = 2;
  8.  
  9. std::string symbols = "0123456789";
  10.  
  11. std::vector<int> symbolChooseTable(MAX_INPUT-INPUT, 0);
  12. std::vector<int> allOnes(INPUT, 1);
  13. symbolChooseTable.insert(symbolChooseTable.end(), allOnes.begin(), allOnes.end());
  14.  
  15. auto GetSelectedSymbols = [&symbols, &symbolChooseTable]()
  16. {
  17. std::string selectedSymbol;
  18. for (size_t i = 0; i<symbolChooseTable.size(); ++i)
  19. {
  20. if (symbolChooseTable[i])
  21. {
  22. selectedSymbol += symbols[i];
  23. }
  24. }
  25. return selectedSymbol;
  26. };
  27.  
  28. do
  29. {
  30. auto selectedSymbols = GetSelectedSymbols();
  31. do
  32. {
  33. std::cout << selectedSymbols << "\n";
  34. } while (std::next_permutation(selectedSymbols.begin(), selectedSymbols.end()));
  35. } while (std::next_permutation(symbolChooseTable.begin(), symbolChooseTable.end()));
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
89
98
79
97
78
87
69
96
68
86
67
76
59
95
58
85
57
75
56
65
49
94
48
84
47
74
46
64
45
54
39
93
38
83
37
73
36
63
35
53
34
43
29
92
28
82
27
72
26
62
25
52
24
42
23
32
19
91
18
81
17
71
16
61
15
51
14
41
13
31
12
21
09
90
08
80
07
70
06
60
05
50
04
40
03
30
02
20
01
10