Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
149453 赖泓宇 13求1+2-3+4-5+……n的值 C++ Accepted 0 MS 268 KB 236 2026-03-13 18:24:26

Tests(10/10):


Code:

#include <iostream> using namespace std; int main() { int n, s=1; cin >> n; if(n==0) s=0; for(int i=2; i<=n; i++) { if(i%2==0) s+=i; else s-=i; } cout << s << endl; return 0; }