|
|
вернуться в форумWhy dosn't work my program on the easiest problem? I wrote a program for 1068 "Sum" - the code is really very easy. Judge program says always me "wrong answer". Where is my mistake? Could anybody help me? program p; var i,n:integer; res:longint; begin read(n); res := 0; if (n >=1) then for i:=1 to n do res := res + i else for i:=1 downto n do res := res + i; write(res); end. What was the problem? What was the problem with your program? Please tell me, 'cause as you can see, Ricardo have the same problem. Re: Why dosn't work my program on the easiest problem? I could only tell you about the right programme. because my English is very bad. Bellow is the answer. var n:longint; begin readln(n); writeln((1+n)*(abs(n-1)+1)div 2); end. |
|
|