Rev | Line | |
---|
[25ae32e] | 1 | #include <stdio.h> |
---|
| 2 | #include <string.h> |
---|
| 3 | |
---|
| 4 | #define MAXLINE 1000 |
---|
| 5 | |
---|
| 6 | main() |
---|
| 7 | { |
---|
| 8 | char buf[MAXLINE+1], outbuf[MAXLINE+1]; |
---|
| 9 | char form[MAXLINE+1]; |
---|
| 10 | int len; |
---|
| 11 | int curpos,nextpos=0; |
---|
| 12 | int a,b; |
---|
| 13 | while(fgets(buf,MAXLINE,stdin)) |
---|
| 14 | { |
---|
| 15 | int n=sscanf(buf,"%d %d",&a,&b); |
---|
| 16 | if(n==2) |
---|
| 17 | { |
---|
| 18 | nextpos=a+b; |
---|
| 19 | fputs(buf,stdout); |
---|
| 20 | } |
---|
| 21 | else |
---|
| 22 | { |
---|
| 23 | if(n==1) |
---|
| 24 | { |
---|
| 25 | curpos=a; |
---|
| 26 | sscanf(buf,"%*d %*s %s",form); |
---|
| 27 | } |
---|
| 28 | else |
---|
| 29 | { |
---|
| 30 | curpos=nextpos; |
---|
| 31 | sscanf(buf,"%*s %s",form); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | if(*form == '*') |
---|
| 35 | len=0; |
---|
| 36 | else |
---|
| 37 | { |
---|
| 38 | char *f = form; |
---|
| 39 | for(len=0; *f; ++f) if(*f != '\\') ++len; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | char *buf1=buf; while(!isalpha(*buf1)) ++buf1; |
---|
| 43 | sprintf(outbuf,"%04i %02i %s", curpos, len, buf1); |
---|
| 44 | fputs(outbuf,stdout); |
---|
| 45 | nextpos = curpos+len; |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.