# 求个算法,我们用java, 麻烦能用java实现不?

0

0

"0123456789,0123456789,0123456789,0123456789,0123456789"

0
public static void main(String[] args) {
System.out.println("请输入:");
Scanner scanner = new Scanner(System.in);
String data = scanner.next();
String[] strs = data.split(",");
List<String> strs1 = new ArrayList<String>();
List<String> strs2 = new ArrayList<String>();
for (String string : strs) {
if (string.length() > 1) {
} else {
}
}

for (int i = 0; i < strs1.size(); i++) {
System.out.print(strs1.get(i));
if (i != strs1.size() -1) {
System.out.print(",");
}
}
System.out.println();
for (int i = 0; i < strs2.size(); i++) {
System.out.print(strs2.get(i));
if (i != strs2.size() -1) {
System.out.print(",");
}
}
}

0

String strs = "12,3,456,7,8";
String[] str = strs.split(",");
List<String> list = new ArrayList<String>();
for (int i = 0; i < str.length; i++) {
List<String> list2 = new ArrayList<String>();
for (int j = 0; j < str[i].length(); j++) {
if (list.size() == 0) {
} else {
for (int l = 0; l < list.size(); l++) {
str[i].substring(j, j + 1));
}
}
}
list = list2;
}
for (int l = 0; l < list.size(); l++) {
System.out.println(list.get(l));
}

0
public static void main(String[] args) {
System.out.println("请输入:");
Scanner scanner = new Scanner(System.in);
String data = scanner.next();
String[] strs = data.split(",");
StringBuffer stringBuffer = new StringBuffer();
for (int j = 0; j < strs[0].length(); j++) {
stringBuffer.setLength(0);
stringBuffer.append(strs[0].charAt(j)).append(",");
for (int n = 0; n < strs[1].length(); n++) {
stringBuffer.setLength(2);
stringBuffer.append(strs[1].charAt(n)).append(",");
for (int m = 0; m < strs[2].length(); m++) {
stringBuffer.setLength(4);
stringBuffer.append(strs[2].charAt(m)).append(",");
for (int b = 0; b < strs[3].length(); b++) {
stringBuffer.setLength(6);
stringBuffer.append(strs[3].charAt(b)).append(",");
for (int k = 0; k < strs[4].length(); k++) {
stringBuffer.setLength(8);
stringBuffer.append(strs[4].charAt(k));
System.out.println(stringBuffer.toString());
}
}
}
}
}
}

0123,45,67,8,9
0,4,6,8,9
0,4,7,8,9
0,5,6,8,9
0,5,7,8,9
1,4,6,8,9
1,4,7,8,9
1,5,6,8,9
1,5,7,8,9
2,4,6,8,9
2,4,7,8,9
2,5,6,8,9
2,5,7,8,9
3,4,6,8,9
3,4,7,8,9
3,5,6,8,9
3,5,7,8,9

0
public static void main(String[] args) {
String str1 = "1111111111,1111111111,1111111111,1111111111,1111111111";
String[] split = str1.split(",");
String s1 = split[0];
String s2 = split[1];
String s3 = split[2];
String s4 = split[3];
String s5 = split[4];
int x = 0;
for (int a = 0; a < s1.toCharArray().length; a++) {
for (int b = 0; b < s2.toCharArray().length; b++) {
for (int c = 0; c < s3.toCharArray().length; c++) {
for (int d = 0; d < s4.toCharArray().length; d++) {
for (int e = 0; e < s5.toCharArray().length; e++) {
x++;
System.err.println(s1.toCharArray()[a] + ""
+ s2.toCharArray()[b] + ""
+ s3.toCharArray()[c] + ""
+ s4.toCharArray()[d] + ""
+ s5.toCharArray()[e]);
}
}
}
}
}
System.err.println(x);
}

0
public class Combination {
public static void combineOutput(String[] str,int index,StringBuffer res){
if(index >= str.length){
System.out.println(res);
return;
}

for(int i = 0;i<str[index].length();i++){
int curIndex = index;
res.append(str[index].charAt(i));
combineOutput(str, ++curIndex,res);
res.deleteCharAt(res.length()-1);
}
}

public static void main(String args[]){
String s = "0123456789,0123456789,0123456789,0123456789,0123456789";
String[] str=s.split(",");
combineOutput(str, 0,new StringBuffer());
}
}

0

0
//main方法
String teststr="12,3,5,6,7";
String[] strings=teststr.split(",");//切割

char[][] strings2=new char[strings.length][];

//下面把它变成字符的二维数组
for(int i=0;i<strings.length;i++){
char cs[]=strings[i].toCharArray();
strings2[i]=new char[cs.length];
for(int j=0;j<cs.length;j++){
strings2[i][j]=cs[j];
}
}
listAll(strings2);//调用函数得到所有的可能性

/**
* 一个二维数组串联能组成的所有可能性
* @param stringss
*/
public static void listAll(char[][] stringss){

int cvalue=1;
int i;
for(i=0;i<stringss.length;i++)
cvalue*=stringss[i].length;

for(int j=0;j<cvalue;j++){
int tmpvalue=1;
char[] cs=new char[stringss.length];
cs[i-1]=stringss[i-1][j%stringss[i-1].length];
tmpvalue=stringss[i-1].length;
for(int k=i-2;k>=0;k--){
cs[k]=stringss[k][j/tmpvalue%stringss[k].length];
tmpvalue*=stringss[k].length;
}
//输出这个数组
for(int m=0;m<cs.length;m++){
System.out.print(cs[m]+"\t");
}
System.out.println();
}
}

0
public static void main(String[] args) {
// TODO Auto-generated method stub

Test1 t = new Test1();
StringBuffer[] s = t.test("1,2,3,4,56");
for(StringBuffer sf :s){
System.out.println(sf.toString().substring(0,sf.toString().lastIndexOf(",")));
}
}

public StringBuffer[] test(String str){
String[] strArray = str.split(",");
int len = 1;
List<char[]> list = new ArrayList<char[]>();
for(int j = 0; j<strArray.length; j++){
String s1 = strArray[j];
char[] chs = s1.toCharArray();
len = chs.length * len;
}

StringBuffer[] sbs = new StringBuffer[len];
for(int i=0; i<len; i++){
sbs[i] = new StringBuffer();
}
for(char[] cs : list){
int csLen = cs.length;
int t = len/csLen;
for(int n=0; n<t; n++){
for(int m=0; m<csLen; m++){
sbs[n*csLen+m].append(cs[m]+",");
}
}

}
// for(StringBuffer sf :sbs){
// System.out.println(sf.toString().substring(0,sf.toString().lastIndexOf(",")));
// }
return sbs;
}