All pastes #281218 Raw Edit

Stuff

public java v1 · immutable
#281218 ·published 2006-12-16 16:39 UTC
rendered paste body
  static String[] permute(String str) {    bling++;    int len = str.length();        if (len > 2) {      blu++;      String[][] result = new String[len][len-1];            for (int i = 0; i < len; i++) {        String help = str.substring(0, i) + str.substring(i+1);        String[] permhelp = permute(help);   // Rekursion        //System.out.println(permhelp);        for (int j = 0; j < len-1; j++)          result[i][j] = str.charAt(i) + permhelp[j];      }            // rückgabe      String[] result2 = new String[fak(len)];      int k = 0;      for (int i = 0; i < len; i++)        for (int j = 0; j < len-1; j++) {          result2[k] = result[i][j];          System.out.println(result2[k] + " k=" + k + " i=" + i + " j=" + j);          k++;        }            return result2;    }            String[] result = new String[2];    if (len == 2) {      bla++;      result[0] = str;      result[1] = "" + str.charAt(1) + str.charAt(0); // "" zur Umwandlung in string    }        return result;  }