fork 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.  
  11. private static void permutation(char[] perm, int pos, String str) {
  12. if (pos == perm.length) {
  13. System.out.println(new String(perm));
  14. } else {
  15. for (int i = 0 ; i < str.length() ; i++) {
  16. perm[pos] = str.charAt(i);
  17. permutation(perm, pos+1, str);
  18. }
  19. }
  20. }
  21.  
  22.  
  23.  
  24. public static void main (String[] args) throws java.lang.Exception
  25. {
  26. char[] perm = new char[3];
  27. permutation(perm, 0, "2424");
  28. }
  29. }
Success #stdin #stdout 0.08s 54876KB
stdin
Standard input is empty
stdout
222
224
222
224
242
244
242
244
222
224
222
224
242
244
242
244
422
424
422
424
442
444
442
444
422
424
422
424
442
444
442
444
222
224
222
224
242
244
242
244
222
224
222
224
242
244
242
244
422
424
422
424
442
444
442
444
422
424
422
424
442
444
442
444