归并排序 递归的地方不懂啊,求指点,我想知道第一个递归一层层递归下去后,后面的两个函数怎么执行的,函数返回的时候,后面两个又是如何执行的,确实费解啊。。。。
void chaild_sort(int a[],int end[],int s,int t)归并排序 递归 递归函数后面的递归函数及其函数的执行
{
void real_sort(int temp[],int end[],int s,int m,int t);
int m;
int temp[sizeof(a)/sizeof(int)];
if(s==t)
{
end[s]=a[s];
}
else
{
m=(s+t)/2;
chaild_sort(a,temp,s,m);
chaild_sort(a,temp,m+1,t);
real_sort(temp,end,s,m,t);
}
}
[解决办法]
递归基础上多了一层递归调用而已!
在你另外一个帖子已经给出回复了
记住一点:函数接口没有返回,也就是没有调用完成,会从里面嵌套进去
一层一层进去调用,然后才向外面一层一层的逆向退回来最外层!
画个图就会清楚明白的!