WA : csu1019 simple line editor

查了很多遍,不知道哪里错了,数组还不够大?

 1 # include <stdio.h>
2 # include <ctype.h>
3
4 # define MAXN 10005
5
6 char a[MAXN];
7 int i = -1, j, T;
8 char ch;
9
10 int main()
11 {
12 freopen("in.txt", "r", stdin);
13 freopen("out.txt", "w", stdout);
14
15 scanf("%d", &T);
16 getchar();
17 while (ch = getchar())
18 {
19 if (isalpha(ch)) a[++i] = ch;
20 else if (ch=='#' && i>=0) --i;
21 else if (ch == '@') i = -1;
22 else
23 {
24 for (j = 0; j <= i; ++j)
25 putchar(a[j]);
26 putchar('\n');
27 --T;
28 if (T==0 || ch==EOF) break;
29 memset(a, 0, sizeof(a));
30 i = -1;
31 }
32 }
33
34 return 0;
35 }



你可能感兴趣的:(editor)