fork(1) download
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. char chs[] = "123";
  8. constexpr unsigned n = sizeof chs - 1;
  9. bool used[n][n][n] = {};
  10. constexpr unsigned nnn = sizeof used;
  11.  
  12. printf("%u %u\n", n, nnn);
  13.  
  14. for (int q = 0, i; q < nnn; ++q)
  15. {
  16. while (used[0][0][i = rand() % nnn]);
  17. used[0][0][i] = true;
  18. printf("%c%c%c\n", chs[i/n/n%n], chs[i/n%n], chs[i%n]);
  19. }
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
3 27
312
232
311
332
223
221
131
212
323
122
123
132
111
133
333
331
233
322
121
211
113
313
321
112
213
231
222