2 câu trả lời
uses crt;
var i,n,s,k:longint;
begin
clrscr;
write('Nhap n: ');readln(n);
k:=-1;
for i:=1 to n do
begin
k:=k*-1;
s:=s+k*i;
end;
writeln('S=',s);
readln
end.
uses crt;
var i, s, n : integer;
begin
clrscr;
write('nhap so n : ');readln(n);
s := 0;
for i := 1 to n do
if i mod 2 = 0 then s := s - i
else s := s + i;
writeln('tong s = ', s);
readln
end.
* Vd : n = 9
=> 1 - 2 + 3 - 4 + 5 - 6 + 7 - 8 + 9 = 5