当前位置: 代码迷 >> Java相关 >> 哪位高手能帮小弟我看上这段代码哪有有关问题,如何改正啊
  详细解决方案

哪位高手能帮小弟我看上这段代码哪有有关问题,如何改正啊

热度:8158   发布时间:2013-02-25 21:44:35.0
谁能帮我看下这段代码哪有问题,怎么改正啊???
Java code
/*输入字符数串,如:String s=”ABC”,输出为:A,B,C,AB,AC,BC,ABC*/import java.util.Scanner;import java.util.*;public class StringChange {    public static void main(String args[]) {        while (true) {            System.out.println("\n 输入字符数串:");            Scanner in = new Scanner(System.in);            Vector<String> v = new StringChange().allot(in.next());            Iterator<String> it = v.iterator();            while (it.hasNext()) {                System.out.print(it.next() + ",");            }        }    }    public Vector allot(String s) {        int len = s.length();        char c[] = new char[len];        s.getChars(0, len, c, 0);        Character ch[] = new Character[len];        String str[] = new String[len];        Vector<String> v = new Vector<String>(len);        for (int i = 0; i < c.length; i++) {            ch[i] = new Character(c[i]);            str[i] = ch[i].toString();        }        for (int i = 0; i < str.length; i++) {            v.add(str[i]);        }        folo(str.length, 2, 3, v, str);        return v;    }        int i = 0;    int r;    int p = -1;    int a[];    public void folo(int len, int r, int num, Vector v, String str[]) {        this.r = r;        for (a[i] = p + 1; a[i] < len - r; a[i]++) {            i++;            r--;            num--;            p++;            if (num > 0)                folo(len, r, num, v, str);            else if (num == 0) {                String m = str[a[0]];                for (int i = 1; i < num; i++) {                    String n = str[a[i]];                    m = m + n;                }                v.add(m);            }        }    }}


------解决方案--------------------------------------------------------
我不是高手,帮楼主顶起,等待高手解答!
------解决方案--------------------------------------------------------
帮楼主顶起,等待高手解答!
  相关解决方案