ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1226. esreveR redrO

WHI WA.
Posted by I am david. Tabo. 9 Nov 2002 22:57
Var i,n,k,nn,bo:integer;
    s,s1,s2,s3:string;
    a:array [1..100] of string[255];
    q,q1:boolean;

begin
  q1:=true;
  repeat
    s:='';q:=false;bo:=1;s1:='';
    readln(s);inc (nn);n:=0;
    for i:=1 to length(s) do
      begin
        if not q1 then
          s1:='';
        if (s[i] in ['a'..'z']) or (s[i] in ['A'..'Z']) then
          begin
            inc (n);q1:=true;
            s1:=s1+s[i];q:=false;
          end
        else
          if ((s[i-1] in ['a'..'z']) or (s[i-1] in ['A'..'Z']))and
             ((s[i+1] in ['a'..'z']) or (s[i+1] in ['A'..'Z']))and
             (s[i]<>' ') then
            begin
              inc (n);q1:=true;
              s1:=s1+s[i];q:=false;
            end
          else
            begin
              if not q then
                for k:=n downto 1 do
                  begin
                    a[nn]:=a[nn]+s1[k];
                    q:=true;
                  end;
              a[nn]:=a[nn]+s[i];inc(n);
              q1:=false;bo:=n;n:=0;
            end;
      end;
  until (eof(input));
  bo:=length (s1);
  for k:=bo downto 1 do
    if (s1[k] in ['a'..'z']) or (s1[k] in ['A'..'Z']) then
      s2:=s2+s1[k]
    else
      s3:=s3+s1[k];
  a[nn]:=a[nn]+s2+s3;
  for i:=1 to nn do
    writeln (a[i]);
end.