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 1059. Expression

Where is wrong?(the following 3 examples are wrong answers)I don't know
Posted by ECUST Multistar 21 Feb 2002 19:17
1:
var n,i:integer;
begin
  read(n);
  writeln(0);
  for i:=1 to n do
  begin
    writeln('X');
    writeln('*');
    writeln(i);
    writeln('+');
  end;
end.
2:
Posted by ECUST Multistar 21 Feb 2002 19:18
2:
var n,i:integer;
begin
  n:=1000;
  writeln(0);
  for i:=1 to n do
  begin
    writeln('X');
    writeln('*');
    if i>=1000 then begin  writeln(i mod 10);writeln(i mod 100 div
10);writeln(i mod 1000 div 100);writeln(i div 1000);end;
    if (i<1000)and(i>=100) then begin writeln(i mod 10);writeln(i mod
100 div 10);writeln(i mod 1000 div 100);end;
    if (i<100)and(i>=10) then begin writeln(i mod 10);writeln(i mod
100 div 10); end;
    if i<10 then writeln(i);
    writeln('+');
  end;
  readln;
end.
2:
Posted by ECUST Multistar 21 Feb 2002 19:18
2:
var n,i:integer;
begin
  read(n);
  writeln(0);
  for i:=1 to n do
  begin
    writeln('X');
    writeln('*');
    if i>=1000 then begin  writeln(i mod 10);writeln(i mod 100 div
10);writeln(i mod 1000 div 100);writeln(i div 1000);end;
    if (i<1000)and(i>=100) then begin writeln(i mod 10);writeln(i mod
100 div 10);writeln(i mod 1000 div 100);end;
    if (i<100)and(i>=10) then begin writeln(i mod 10);writeln(i mod
100 div 10); end;
    if i<10 then writeln(i);
    writeln('+');
  end;
end.
3:
Posted by ECUST Multistar 21 Feb 2002 19:21
3:
var n,i:integer;
begin
  read(n);
  writeln(0);
  for i:=1 to n do
  begin
    writeln('X');
    writeln('*');
    if i>=1000 then begin  writeln(i div 1000);writeln(i mod 1000 div
100);writeln(i mod 100 div 10);writeln(i mod 10);end;
    if (i<1000)and(i>=100) then begin writeln(i mod 1000 div
100);writeln(i mod 100 div 10);writeln(i mod 10);end;
    if (i<100)and(i>=10) then begin writeln(i mod 100 div 10);writeln
(i mod 10); end;
    if i<10 then writeln(i);
    writeln('+');
  end;
end.
This 2: is wrong ,the next 2 is right
Posted by ECUST Multistar 21 Feb 2002 19:22
> 2:
> var n,i:integer;
> begin
>   n:=1000;
>   writeln(0);
>   for i:=1 to n do
>   begin
>     writeln('X');
>     writeln('*');
>     if i>=1000 then begin  writeln(i mod 10);writeln(i mod 100 div
> 10);writeln(i mod 1000 div 100);writeln(i div 1000);end;
>     if (i<1000)and(i>=100) then begin writeln(i mod 10);writeln(i
mod
> 100 div 10);writeln(i mod 1000 div 100);end;
>     if (i<100)and(i>=10) then begin writeln(i mod 10);writeln(i mod
> 100 div 10); end;
>     if i<10 then writeln(i);
>     writeln('+');
>   end;
>   readln;
> end.