|
|
back to boardDiscussion of Problem 1068. SumProgramme 1068 o Greetings to all. I want to learn that such here with a problem number 1068, I all have correctly written that kompiliator from me demands, tell please. Here the *_Pascal_* language program: ___________________________________________ var s,i,n:integer; BEGIN s:=0; read(n); if (n>=0) then for i:=1 to N do s:=s+i; if (n<=0) then for i:=-1 downto N do s:=s+i; Writeln(s); END. ___________________________________________ Re: Programme 1068 o please, help me. Read statement carefully Posted by vgu 31 Dec 2010 00:49 You need calculate sum between 1 and N. So, if n<=0, you should sum 1,0,-1,-2,...N. But not -1,-2,...-N. Re: Read statement carefully Thank you. |
|
|