All pastes #3467 Raw Edit

Anonymous

public java v1 · immutable
#3467 ·published 2004-12-28 22:24 UTC
rendered paste body
/* * Permutationen von char[] */public class permu {    public static char[] liesZeichenfolge() {        System.out.print("char[]: ");        String s = "";        try {             s = new java.io.BufferedReader(                    new java.io.InputStreamReader(System.in)).readLine();        }        catch (java.io.IOException e) {}        return s.toCharArray();    }    static char[] a,printMe;    public static void perm(int pos, int done) {        char pre = '\0';        if(pos != a.length) {            for(int x=0;x<a.length;x++)                if(a[x] != pre && (done&(1<<x)) == 0) {                    pre = a[x];                    printMe[pos] = pre;                    perm(pos+1,(done|(1<<x)));                }        }        else            System.out.println(new String(printMe));    }    public static void main(String [] args) {        a = liesZeichenfolge();        printMe = new char[a.length];        perm(0,0);    }}