今天在做TJU 的1169的时候,终于感受到了栈空间的有限了.出现问题的代码如下:
#include <iostream>
using namespace std;
int main()
{
long hi[1000001];
//中间部分省略
return 0;
}
在运行的时候不断出错,肯定是栈空间耗尽。最后找到解决方法,就是把大数组一道全局变量区。这样的话,程序正常运行。原因是因为在函数里的栈空间有限.
#include <iostream>
using namespace std;
long hi[1000001];
int main()
{
//省略
return 0;
}