|
|
вернуться в форумОбщий форумWho can help me? Thank you! Послано Roger 21 июн 2001 18:35 I'm a newbie of using c++,who can tell me why my program get crash! #include <iostream.h> #include <string.h> #include <stdlib.h> const long maxn = 10000; const long interval = 600; long block[maxn],i,no,t; char *p,s[20]; void main() { for (i=0;i<maxn;i++) block[i]=0; while (!(cin.eof())) { cin.getline(s,19); if ((strchr(s,'+')==NULL)&&(strchr(s,'.')==NULL)) break; if (!(strchr(s,'+')==NULL)){ p = s; t = atoi(p); for (i=0; i<maxn; i++) if ((block[i]==0)||(t-block[i]>=interval)) break; block[i]=t; i++; cout<<i<<"\n"; } else { p = s; t = atoi(p); p = strchr(s,'.')+1; no = atoi(p); no--; if ((t-block[no]>=interval)||(block[no]==0)) cout<<'- '<<"\n"; else { block[no] = t; cout<<'+'<<"\n"; } } } } |
|
|