问题遇到的现象和发生背景
为什么我这里用const int N = 1e7后不能输入,而1e6却是正常的
遇到的现象和发生背景,请写出第一个错误信息
用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%
#include<iostream>
#include<cmath>
using namespace std;
const int N=1e6+10;
int main()
{
char x,ch[N];
int k,a=0,b=0;
while(cin>>x){
if(x=='E')break;
ch[k++]=x;
}
for(int i=0;i<k;i++){
if(ch[i]=='W')a++;
else if(ch[i]=='L')b++;
if(max(a,b)>=11&&fabs(a-b)>=2){
cout<<a<<":"<<b<<endl;
a=b=0;
}
}
cout<<a<<":"<<b<<endl;
puts("\n");
a=b=0;
for(int i=0;i<k;i++){
if(ch[i]=='W')a++;
else if(ch[i]=='L')b++;
if(max(a,b)>=21&&fabs(a-b)>=2){
cout<<a<<":"<<b<<endl;
a=b=0;
}
}
cout<<a<<":"<<b<<endl;
return 0;
}
运行结果及详细报错内容
我的解答思路和尝试过的方法,不写自己思路的,回答率下降 60%
const int N=1e7一直无法输入,改成1e6后就正常了,是不是const有使用边界?