|
|
back to boardDiscussion of Problem 1068. SumMy code is wrong... Why? Posted by Shatll 17 Dec 2002 23:23 I submit this problem and got WA? Wazzup??? Var N, J, Sum: Integer; I: Word; Begin Read (N); Sum:= 0; J:= 1; If N >= 1 Then Begin For I:= I to N do Sum:= Sum + I; End Else For I:= 1 to 2 + Abs (N) do Begin Sum:= Sum + J; Dec (J); End; WriteLn (Sum); End. Re: My code is wrong... Why? > Var > N, J, Sum: Integer; > I: Word; Your variables are too small. Just change 'Word' and 'Integer' into 'LongInt', and then you will be right. |
|
|