-
Notifications
You must be signed in to change notification settings - Fork 0
/
dealGram.c
37 lines (35 loc) · 958 Bytes
/
dealGram.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char lines[100][500];
char tmplines[500];
char a[12];
int lineno = 0;
int main(){
freopen("./gram.out", "r", stdin);
FILE* fout = fopen("./gramtmp.txt", "w");
int i = 1;
while(i <= 4092){
lineno = 0;
fgets(lines[lineno], 500, stdin);
lineno++; i++;
do{
fgets(tmplines, 500, stdin);
// printf("%d: %d %s\n", i, strlen(tmplines), tmplines);
i++;
}while(strlen(tmplines) != 1);
do{
fgets(lines[lineno], 500, stdin);
// printf("%d: %d %s\n", i, strlen(lines[lineno]), lines[lineno]);
lineno++; i++;
}while(strlen(lines[lineno - 1]) != 1);
fputs(lines[0], fout);
sprintf(a, "%d", lineno - 2);
fputs(a, fout);
for(int j = 1; j < lineno; j++){
fputs(lines[j], fout);
}
}
fclose(fout);
return 0;
}