|
|
вернуться в форумHelp! (Pascal) Послано JIm 12 дек 2012 23:51 readln(a); b:=0; if a>=0 then for i:=1 to a do begin b:=b+i; end else for i:=1 downto a do begin b:=b+i; end; writeln(b); Edited by author 13.12.2012 00:05 Re: Help! (Pascal) Why not check that the number is positive or negative. You can simply like this: for i := 1 to a do begin b : = (b + i; end. Change and try it. Should earn. Good luck :) ! Re: Help! (Pascal) I may be mistaken, but the program is not true, namely, in the test, when the input number 0 (a = 0), the output of your number will be 0 instead of 1 .. And this is just a linear program ... that is the sum of an arithmetic progression .. Sorry for my English :) |
|
|