|
|
вернуться в форумI always get Crash!!!!!!Please tell me why?Here is my program #include<iostream.h> #include<string.h> #include<stdio.h> int l,p; char s[3000000]; void proc(int); int main() { int n,i,c; int ans[1002]; cin>>n; for(i=1;i<=n;i++){ l=0; do{ c=getc(stdin); s[l++]=(char)c; }while(c!='\n'); l--; p=0; proc(0); ans[i]=p; }for(i=1;i<=n;i++){ if(ans[i]==0) cout<<"NO"<<endl; else cout<<"YES"<<endl; } return 0; } void proc(int i){ if(i==l) p=1; if(p==0){ if(i+1<l) if(s[i]=='i' && s[i+1]=='n') proc(i+2); if(i+2<l) if(s[i]=='o' && s[i+1]=='n' && s[i+2]=='e') proc(i+3); if(i+4<l) if(s[i]=='p' && s[i+1]=='u' && s[i+2]=='t' && s[i+3]=='o' && s[i+4]=='n') proc(i+5); if(i+2<l) if(s[i]=='o' && s[i+1]=='u' && s[i+2]=='t') proc(i+3); if(i+5<l) if(s[i]=='o' && s[i+1]=='u' && s[i+2]=='t' && s[i+3]=='p' && s[i+4]=='u' && s[i+5]=='t') proc(i+6); if(i+4<l) if(s[i]=='i' && s[i+1]=='n' && s[i+2]=='p' && s[i+3]=='u' && s[i+4]=='t') proc(i+5); return; } } Maybe it is that... I have immediately noticed a bug in your program. In the statement it is said that the total length of the strings might reach 10^7 and this could cause a single one of them to be with length more than 3000000 your upper bound for string length. This would cause your crash... |
|
|