#include <stdio.h>
#define LENGTH 16
void makeBranches(int, int);
void display(int, int);
int main(){
makeBranches(0, LENGTH-1);
}
void makeBranches(int left, int right){
if(left >= right){
return;
} else{
display(left, right);
makeBranches(left, (right+left)/2);
makeBranches((right+left/2)+1, right);
}
}
void display(int left, int right){
printf("%d, %d", left, right);
int mid = (left+right)/2;
int i;
for(i = left; i <= right; i++){
if(i == mid)
printf("X");
else
printf("-");
}
if(right == LENGTH-1)
printf("\n");
}
我遇到的问题是 makeBranches 的第二次调用仅使用导致第一次调用 makeBranches 返回的值而不是第一次调用使用的原始值执行。