|  | 
|  | 
| вернуться в форум | Please, help! (Wrong Answer, Problem 1068) vara, k, b: integer;
 
 begin
 {$IFNDEF ONLINE_JUDGE}
 ASSIGN (input, 'input.txt');
 reset (input);
 assign (output, 'output.txt');;
 rewrite (output);
 {$ENDIF}
 readln (input, a);
 if a>0 then for k:=0 to a do b:=b+k else for k:=1 downto a do b:=b+k;
 writeln (output, b);
 {$IFNDEF ONLINE_JUDGE}
 close (input);
 close (output);
 {$ENDIF}
 end.
That > var>  a, k, b: integer;
 >
 > begin
 >  {$IFNDEF ONLINE_JUDGE}
 >  ASSIGN (input, 'input.txt');
 >  reset (input);
 >  assign (output, 'output.txt');;
 >  rewrite (output);
 >  {$ENDIF}
 >  readln (input, a);
 >  if a>0 then for k:=0 to a do b:=b+k else for k:=1 downto a do
 b:=b+k;
 >  writeln (output, b);
 >  {$IFNDEF ONLINE_JUDGE}
 >  close (input);
 >  close (output);
 >  {$ENDIF}
 > end.
That's a tuff one ! :)  Firstly, use for..to instead of for..downto - it doesn't work properly on timus. And, secondly, variables are not always equal to 0 at the start of program run :) (-) | 
 | 
|