|
谢谢,我不会JAVA,不知你的程序是否经过调试,结果是否正确,
但是普通读你的程序可能不符合我的要求,你的递归主程序可能是
public int showteamchoice(int n,int y){
int temp;
if(y==1){
temp = n;
}
else if(n==y){
temp = 1;
}
else{
temp=showteamchoice(n-1,y-1);
temp=temp+showteamchoice(n-1,y);
}
return temp;
}
有多个分号
public void showteam(int n,int k,int index,String output){
if(k==0){ //one kind of the combine
System.out.println(output);
return;
}
else if(index==nItems&&k!=0){ //not enough items for the combine
return;
}
else {
int temp=k;
String stemp=output;
while(index<=nItems-1){ //the loop is to decide the first items of the combine.
temp=k;
stemp=output;
stemp=stemp+","+a[index];
this.showteam(n-1, temp-1, index+1, stemp);
index=index+1;
}
}
}
}
也有多个分号
应该是
public void showteam(int n,int k,int index,String output){
if(k==0){System.out.println(output)}
else if(index==nItems&&k!=0){return}
else {
WHile(index<=nItems-1){this.showteam(n-1, temp-1, index+1, stemp)}
};
}
这样的结构,才叫递归过程中没有分号;
再一次谢谢你
|