带你学C带你飞第35节课课后习题对于比赛问题代码的优化
#include <stdio.h>#define max_team_num 64
int schedule;
//n,m代表横纵坐标,i代表当前坐标的值,num代表分割的区域的边长。初始化range(1,1,1,8)代表在(1,1)坐标上的值为1,方框边长为8,之后进行迭代
void range(int i, int n, int m, int num)
{
if (num==2)
{
schedule = i;
schedule = i;
schedule = i+1;
schedule = i+1;
}
else
{
range(i, n, m, num/2);
range(i+num/2, n+num/2, m, num/2);
range(i+num/2, n, m+num/2, num/2);
range(i, n+num/2, m+num/2, num/2);
}
}
int main(void)
{
int num;
printf("please input the team number:");
scanf("%d",&num);
//
if ( num & num-1 )
{
printf("team number must be the multiple of 2:\n");
return -1;
}
//
range(1,1,1,num);
printf("队伍\t");
for (int i=1; i<num; i++)
{
printf("第%d天\t",num);
}
putchar('\n');
//
for (int i=1; i<num+1; i++)
{
for (int j=1; j<num+1; j++)
{
printf("%d\t",schedule);
}
putchar('\n');
}
return 0;
}
6666666666666666 {:5_95:} 11111111111111111 {:5_106:}{:5_106:} {:10_254:} {:10_254:} 支持 {:5_109:} {:10_256:} {:10_256:} {:10_256:} {:10_256:} {:10_257:} {:10_280:} {:10_249:} {:10_266:} 额
{:5_109:} 666666666
页:
[1]
2