기본 케이스가없는 경우 재귀 실행 후 명령문은 언제 실행됩니까? 마다 재귀 재귀 기능으로 다시 제어를 보내면기본 케이스가없는 재귀와 재귀 함수가있는 문이없는 재귀
void fun(int x,int y){
statement 1;
statement 2;
fun(x',y');
statement 3;
statement 4;
}
여기 문 1 및도 2는베이스 cases.When는 문 (3) 및 (4)가 실행한다하지?
내 질문은이 코드 https://ideone.com/lEKxW5과 관련이 있습니다. 내가 준 링크에서 24 번째 행 다음의 명령문이 실행되거나 재귀 실행 후 말합니까?
LOOK AT THE LINK OF THE CODE BEFORE ANSWERING .
void dfsBipartiteColor(int x, int y, int c)
{
// If we got to paint the cell:
if ((board[x][y] == 'X') && (color[x][y] == -1)) {
// Color it:
color[x][y] = c;
// Special case: We have foudn that there is at least one X:
result = std::max(result, 1);
// Try the adjacent hexagons:
for (int nx = max(0, x-1); nx <= min(n-1, x+1); nx++) {
for (int ny = max(0, y-1); ny <= min(n-1, y+1); ny++) {
// The hexagon is adjacent and has an X:
if ((nx - x != ny - y) && (board[nx][ny] == 'X')) {
// continue the DFS, negate the color:
dfsBipartiteColor(nx,ny, !c);//
// Special case: We now know there are two adjacent X:
result = std::max(result, 2);
// If the color is not consistent, the graph is not bipartite:
if (color[nx][ny] == c) {
result = 3;
}
}
}
}
}
위의 코드에서 재귀 실행 후 명령문은 언제 실행됩니까?
코드를 단계별로 실행하고 작동 원리를 알아 봅니다. 그것은 훨씬 더 계몽적이고 배울 좋은 기술입니다. – NathanOliver
예 코드에서 수행했지만 재귀 실행 후 또는 순서가 명확하지 않은 경우 언제입니까 – mathematicalerdos
아니요 코드를 단계별로 실행하지 않았습니다. 그렇게했다면 실행되는 것과 실행되는시기가 정확히 표시됩니다. – NathanOliver