Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
75682 陈昊然 13求1+2-3+4-5+……n的值 C++ Accepted 0 MS 268 KB 203 2024-05-28 19:04:42

Tests(10/10):


Code:

#include <bits/stdc++.h> using namespace std; int main (){ int a,j=1,o=0; cin>>a; for(int i=2;i<=a;i++){ if (i%2==0){ o=o+i; }else{ j=j-i; } } cout<<j+o; return 0; }