Re: [問題] 動態調整深度的迴圈(loop)
迴圈的;
int max=4, input=5;
int *args=new int[input];
for(int i=0; i<pow((double)max, input); ++i) {
for(int j=input; j>0; --j) {
args[input-j]=(int)(i/pow((double)max, j-1))%4;
if(j!=input&&args[input-j-1]>args[input-j]) {
++i, ++j;
}
}
for(int j=0; j<input; ++j) {
cout<<" "<<args[j];
}
cout<<endl;
}
delete[] args;
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.68.164.15
→
10/29 14:25, , 1F
10/29 14:25, 1F
→
10/29 14:26, , 2F
10/29 14:26, 2F
討論串 (同標題文章)
完整討論串 (本文為第 5 之 7 篇):