Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
124002 田子熙 13求1+2-3+4-5+……n的值 C++ Compile Error 0 MS 0 KB 182 2025-07-10 15:51:28

Tests(0/0):


Code:

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


Run Info:

Main.cc: In function 'int main()':
Main.cc:7:6: error: 'i' was not declared in this scope
   if(i==1 || i%2==0){
      ^