2 câu trả lời
uses crt;
var i,n , s : longint;
begin clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
if i mod 2=0 then s:=s-i else s:=s+i ;
write('Tong la :', s);
readln
end.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,s=0;
cin>>n;
for(int i=1;i<=n;i++){
if(i%2==0){
s-=i;
}
else{
s+=i;
}
}
cout<<s;
//samon247
return 0;
}