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 1068. Sum

What's wrong?
Posted by Rick 3 Sep 2002 02:22
PROGRAM SUMAS (INPUT,OUTPUT);
VAR
SUM, W, X, Y, Z:LONGINT;

BEGIN

READLN(input, X);
     IF X>0 THEN
     BEGIN
        SUM:=0;
        FOR Y:=0 TO X DO

        SUM:=SUM+Y;
        WRITE(output, SUM);

     END
     ELSE IF X<=0 THEN
     BEGIN
          SUM:=0;
          FOR Y:=1 DOWNTO X DO

          SUM:=SUM+Y;
          WRITE(output, SUM);

    END;
END.
Re: What's wrong?
Posted by Zahid Munir Kallal 16 Aug 2003 02:55
> PROGRAM SUMAS (INPUT,OUTPUT);
> VAR
> SUM, W, X, Y, Z:LONGINT;
>
> BEGIN
>
> READLN(input, X);
>      IF X>0 THEN
>      BEGIN
>         SUM:=0;
>         FOR Y:=0 TO X DO
>
>         SUM:=SUM+Y;
>         WRITE(output, SUM);
>
>      END
>      ELSE IF X<=0 THEN
>      BEGIN
>           SUM:=0;
>           FOR Y:=1 DOWNTO X DO
>
>           SUM:=SUM+Y;
>           WRITE(output, SUM);
>
>     END;
> END.



I don't know Pascal, but one thing is that the condition should X<1
and X>1 and X=0