Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
124006 | 田子熙 | 13求1+2-3+4-5+……n的值 | C++ | Accepted | 1 MS | 272 KB | 184 | 2025-07-10 15:52:27 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,s=0; cin>>n; for(int a=1;a<=n;a++){ if(a==1 || a%2==0){ s+=a; }else{ s-=a; } } cout<<s; }