e35递归问题
不是很看得懂能不能来个大佬给个注释帮助理解#include <stdio.h>
#define MAX_NUM 64
int schedule;
int arrange(int begin, int num);
int arrange(int begin, int num)
{
int i, j;
if (num == 2)
{
schedule = begin;
schedule = begin + 1;
schedule = begin + 1;
schedule = begin;
return 0;
}
arrange(begin, num/2);
arrange(begin + num/2, num/2);
for (i = begin + num/2; i < begin + num; i++)
{
for (j = num/2 + 1; j <= num; j++)
{
schedule = schedule;
}
}
for (i = begin; i < begin + num/2; i++)
{
for (j = num/2 + 1; j <= num; j++)
{
schedule = schedule;
}
}
}
int main(void)
{
int num, i, j;
printf("请输入参赛的队伍数量:");
scanf("%d", &num);
// 检查num是否2的N次方
// 注意,这里是&,不是&&
// &是按位与操作,1&1==1,0&1==0,0&0 == 0
if (num & num - 1)
{
printf("参数队伍的数量必须是2的N次方!\n");
return -1;
}
arrange(1, num);
printf("编 号");
for (i = 1; i < num; i++)
{
printf("\t第%d天", i);
}
putchar('\n');
for (i = 1; i <= num; i++)
{
for (j = 1; j <= num; j++)
{
printf("%3d\t", schedule);
}
putchar('\n');
}
return 0;
}
吼吼吼吼 {:5_102:} 学习学习
页:
[1]