调试函数时的疑惑
查看原帖
调试函数时的疑惑
867224
miaoshou楼主2024/9/10 19:20

测试n=3时: 在第一次开始递归调用

handle(a, x, 1 + s / 2, s / 2);
```时,i按理来说应该等于1+s/2,也就是5,但调试时发现i被赋值成464了,这是为什么

```cpp
int a[1100][1100] = {0};
	int n;
	cin >> n;
	int t = pow(2, n);
	handle(a, 1, 1,t);
void handle(int a[][1100], int x, int y,int s)
{
	int i;
	for ( i = y; i <= s / 2; i++)
	{
		for (int j = x; j <= s / 2; j++)
		{
			a[i][j] = 1;
		}
	}
	if (s == 1) return;
	handle(a, x, 1 + s / 2, s / 2);
	handle(a, 1+s/2, y, s / 2);
	handle(a, 1+s/2, 1 + s / 2, s / 2);
}
2024/9/10 19:20
加载中...