看板 C_and_CPP 關於我們 聯絡資訊
void dyn_depth_loop(int max, int depth) { vector<int> counter(depth, 0); while(1){ // ... // function body // ... // increase the loop counter for(int i = 0; i < depth; ++i){ ++counter[i]; if(counter[i] < max){ // no need to carry // reset the counters of inner loops fill(&counter[0], &counter[i], counter[i]); break; } else { if(i == depth - 1) // reach the end return; } } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.29.108