解决方案 »

  1.   

    全排列,参考网上。
    public static void select(char[] buf, int start, int end, char[] buf0) {
    if (start == end) {
    for (int i = 0; i <= end; i++) {
    if (buf[0] != 'x' && buf[2] != 'x' && buf[2] != 'z')
    System.out.print(buf[i]);
    }
    } else {
    for (int i = start; i <= end; i++) {
    char temp = buf[start];
    buf[start] = buf[i];
    buf[i] = temp;
    select(buf, start + 1, end, buf0); temp = buf[start];
    buf[start] = buf[i];
    buf[i] = temp;
    }
    }
    } public static void main(String[] args) { char buf1[] = { 'a', 'b', 'c' }; char buf2[] = { 'x', 'y', 'z' }; select(buf2, 0, buf2.length - 1, buf1); }