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

Why this program get Compilation error?
Posted by eeeeeeee 28 Feb 2007 19:18
var st:array [1..100] of string;
    qwe:string;
    i,w,n,j,k,l:longint;

Procedure prover(q:longint);
var e:longint;
begin
 w:=0;
 for e:=q to length(st[i]) do
 begin
  if (st[i][e] in ['a'..'z']) or (st[i][e] in ['A'..'Z']) then
  begin
   inc(w);
   qwe:=qwe+st[i][e];
  end else exit;
 end;
end;

begin
 while not eof do
 begin
  inc(n);
  readln(st[n]);
 end;
 for i:=1 to n do
 begin
  for j:=1 to length(st[i]) do
  begin
   if st[i][j]=' ' then write(' ') else
   begin
    if (st[i][j] in ['a'..'z']) or (st[i][j] in ['A'..'Z']) then
    begin
     qwe:='';
     prover(j);
     for l:=w downto 1 do write(qwe[l]);
     j:=j+w-1;
    end else write(st[i][j]);
   end;
  end;
  writeln;
 end;
end.
Re: Why this program get Compilation error?
Posted by KIRILL(ArcSTU) 28 Feb 2007 21:59
eeeeeeee wrote 28 February 2007 19:18
var st:array [1..100] of string;
    qwe:string;
    i,w,n,j,k,l:longint;

Procedure prover(q:longint);
var e:longint;
begin
 w:=0;
 for e:=q to length(st[i]) do
 begin
  if (st[i][e] in ['a'..'z']) or (st[i][e] in ['A'..'Z']) then
  begin
   inc(w);
   qwe:=qwe+st[i][e];
  end else exit;
 end;
end;

begin
 while not eof do
 begin
  inc(n);
  readln(st[n]);
 end;
 for i:=1 to n do
 begin
  for j:=1 to length(st[i]) do
  begin
   if st[i][j]=' ' then write(' ') else
   begin
    if (st[i][j] in ['a'..'z']) or (st[i][j] in ['A'..'Z']) then
    begin
     qwe:='';
     prover(j);
     for l:=w downto 1 do write(qwe[l]);
     j:=j+w-1;                        // You can't  change j in loop!!!
    end else write(st[i][j]);
   end;
  end;
  writeln;
 end;
end.

j:=j+w-1;         // You can't  change j in loop!!!

Edited by author 28.02.2007 22:03