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

Where is wrong?
Posted by msi 25 Apr 2003 13:12
var
s,s2: string;
k,i,l,Ls,j: longint;
a: boolean;
begin
 repeat
 s:='';
 s2:='';
 k:=1;
 j:=0;
 readln(s2);
 s:=s2;
 Ls:=length(s2);
if (Ls>0) and (s<>' ') then
  repeat
  if (k-1)<=Ls then begin
  a:=false;
  l:=k;
           repeat
           if ((s[k]<='z') and (s[k]>='a')) or ((s[k]<='Z') and (s[k]
>='A')) or (s[k]='-') then k:=k+1 else a:=true;
           until a or (k>Ls);

      for i:=k-1 downto l do
      begin
      if s[i]<>'-' then begin j:=j+1; write(s[i]);  end;
      end;

if j<Ls then begin
      repeat
      write(s[k]);
      j:=j+1;
      k:=k+1;
      until ((s[k]<='z') and (s[k]>='a')) or ((s[k]<='Z') and (s[k]
>='A')) or (j>=Ls);
                      end; end;

  until k>=Ls;
until eof;
end.
have you noticed about last word? which may not ended by space? (-)
Posted by Locomotive 25 Apr 2003 18:56
> var
> s,s2: string;
> k,i,l,Ls,j: longint;
> a: boolean;
> begin
>  repeat
>  s:='';
>  s2:='';
>  k:=1;
>  j:=0;
>  readln(s2);
>  s:=s2;
>  Ls:=length(s2);
> if (Ls>0) and (s<>' ') then
>   repeat
>   if (k-1)<=Ls then begin
>   a:=false;
>   l:=k;
>            repeat
>            if ((s[k]<='z') and (s[k]>='a')) or ((s[k]<='Z') and (s
[k]
> >='A')) or (s[k]='-') then k:=k+1 else a:=true;
>            until a or (k>Ls);
>
>       for i:=k-1 downto l do
>       begin
>       if s[i]<>'-' then begin j:=j+1; write(s[i]);  end;
>       end;
>
> if j<Ls then begin
>       repeat
>       write(s[k]);
>       j:=j+1;
>       k:=k+1;
>       until ((s[k]<='z') and (s[k]>='a')) or ((s[k]<='Z') and (s[k]
> >='A')) or (j>=Ls);
>                       end; end;
>
>   until k>=Ls;
> until eof;
> end.