#include<stdio.h>
#include <string.h>
int y[2000] = {0};
int x[2000] = {0};
int func(int data){
if(data == 1){
printf("end number is %d\n",y[data]);
}
int i,r,n = 1;
for(i = 1;i <= data; i++){
if(i % 2 == 1){
y[i] = -1;
}else{
x[n++] = y[i];
}
}
memset(y,-1,sizeof(y));
for(r = 1;r < n;r++){
y[r] = x[r];
}
func(n-1);
return 0;
}
int main(){
int data;
printf("you input nuumber:\n");
scanf("%d",&data);
int i;
for(i = 1;i < data+1;i++){
y[i] = i;
}
func(data);
return 0;
}
为什么执行了这个程序之后能得到正确的答案 但是运行结果却有段错误