bai 4
canhquydev
plain_text
2 years ago
319 B
25
Indexable
#include <iostream>
#include <math.h>
using namespace std;
int main(){
int n, s = 0;
cout << "Nhap n = ";
cin >> n;
for(int i = 1; i <= n; i++){
if(i % 2 == 0){
s = s + -i*i;
}
else{
s = s + i*i;
}
}
cout << "S= " << s;
}
Editor is loading...
Leave a Comment