Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
4649 | fs_5028 | 13求1+2-3+4-5+……n的值 | C++ | Accepted | 0 MS | 256 KB | 205 | 2024-08-26 18:27:16 |
#include<iostream> using namespace std; int main(){ int a,b=1; cin>>a; for(int i=2;i<=a;i++){ if(i%2==0){ b+=i; } else{ b-=i; } } cout<<b; return 0; }