fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main(String[] args) {
  11. int arraySize = 5;
  12. Set<String> set = new HashSet<>();
  13. for (int y = 0; y <arraySize ; y++) {
  14. for (int x = 0; x < arraySize; x++) {
  15. if (y == x) continue; // такие if в начале каждого цикла, чтобы исключить повторы цифр внутри последовательности
  16.  
  17. for (int i = 0; i < arraySize; i++) {
  18. if (x == i || y == i) continue;
  19.  
  20. for (int j = 0; j < arraySize; j++) {
  21. if (i == j || x == j || y == j) continue;
  22.  
  23. for (int k = 0; k < arraySize; k++) {
  24. if (j == k || i == k || x == k || y == k) continue;
  25.  
  26. String e = "" + x + i + j + k;
  27. set.add(e);
  28. }
  29. }
  30. }
  31.  
  32. }
  33. }
  34.  
  35. for (String s : set) {
  36. System.out.println(s);
  37. }
  38.  
  39. System.out.println("Размер: " + set.size());
  40.  
  41. }
  42. }
Success #stdin #stdout 0.1s 28052KB
stdin
Standard input is empty
stdout
4210
2034
2430
1340
3241
2031
3120
3240
2304
0123
0124
2301
0243
4203
4102
0142
1230
3012
2043
2041
0413
2314
0412
3402
0134
3401
0132
1342
2431
3124
2310
4213
4230
4231
3024
3420
1240
3142
3021
3140
0423
1234
3412
0421
0143
3014
3410
4103
4120
4123
2341
2340
0314
1403
1402
0312
0431
0432
1243
3421
4130
4132
4012
4013
3042
3041
0324
2104
0321
2103
4021
4023
1032
3210
1304
0213
1423
0214
1302
3204
1024
1420
1023
3201
4031
4032
4310
1043
1042
2130
2403
2401
1432
3214
0341
0342
1034
1430
4301
4302
4320
4321
4201
2143
0241
2140
1204
1324
2413
1203
0234
3104
2014
2410
0231
2134
1320
2013
3102
4312
Размер: 120