比赛 20110722 评测结果 AAAAAWAATAA
题目名称 解析程序 最终得分 81
用户昵称 Oo湼鞶oO 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-07-22 11:27:40
显示代码纯文本
var
s:array[0..1000]of string;
f:array[0..1000]of boolean;
i,n,t,j:longint;
c:char;

procedure wrong;
begin
    writeln('Wrong Format');
    close(input);close(output);
    halt;
end;

procedure xxx;
var
c:char;
begin
     f[t]:=true;
    repeat
    read(c);
    if c='"' then begin
        read(c);
        if c='"' then s[t]:=s[t]+c
        else  begin
            while (ord(c)=9)or(ord(c)=32) do read(c);
            if (c=',')or(ord(c)=13) then begin
                inc(t);n:=0;exit;
            end
            else wrong;
        end;

    end
    else s[t]:=s[t]+c;
    until t=10000;
end;

begin
assign(input,'parser.in');reset(input);
assign(output,'parser.out');rewrite(output);
    t:=1;n:=0;
    while not eof do begin
        read(c);
        if n=0 then begin
            case ord(c) of
            34:begin xxx;continue;end;
            13:begin readln;continue;end;
            44:continue;
            10:continue;
            9:continue;
            32:continue;
            end;
            inc(n);
            s[t]:=s[t]+c;
        end
        else begin
            case ord(c) of
            34:begin
                wrong;
            end;
            44:begin
                inc(t);n:=0;continue;
            end;
            13:begin
                readln;inc(t);n:=0;continue;
            end;
            end;
            s[t]:=s[t]+c;
        end;
    end;
    while s[t]='' do dec(t);
    for i:=1 to t do begin
        if not f[i] then begin
            n:=length(s[i]);
            while (s[i][n]=' ')or(ord(s[i][n])=9) do dec(n);
            j:=1;
            while (s[i][j]=' ')or(ord(s[i][j])=9) do inc(j);
            for j:=j to n do write(s[i][j]);
            writeln;
        end
        else writeln(s[i]);
    end;
close(input);close(output);
end.