0
考慮下面的代碼所有可能的非遞減序列
double t0 = lower;
for(double t1 = t0; t1 < upper+0.2 ; t1 = t1 + 0.1){
for(double t2 = t1; t2 < upper+0.2 ; t2 = t2 + 0.1){
for(double t3 = t2; t3 < upper+0.2 ; t3 = t3 + 0.1){
for(double t4 = t3; t4 < upper+0.2 ; t4 = t4 + 0.1){
for(double t5 = t4; t5 < upper+0.2 ; t5 = t5 + 0.1){
bw.write(t0+"\t"+t1+"\t"+t2+"\t"+t3+"\t"+t4+"\t"+t5+"\n");
}
}
}
}
}
代替具有5個嵌套循環,如果我要採取作爲參數某個k = 5,其將輸出相同的。我希望爲任何k計算這樣一個序列。
遞歸...... –