Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
112106 徐齐力 13求1+2-3+4-5+……n的值 C++ Compile Error 0 MS 0 KB 843 2025-03-08 14:08:43

Tests(0/0):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int a,b=1,i; cin>>a; for(i=2;i<=a;i++) { if(i%2==0) b+=i; else b-=i; } cout<<b; return 0; }#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int a,b=1,i; cin>>a; for(i=2;i<=a;i++) { if(i%2==0) b+=i; else b-=i; } cout<<b; return 0;


Run Info:

Main.cc:19:2: error: stray '#' in program
 }#include  // cin\cout\endl
  ^
Main.cc:19:3: error: 'include' does not name a type
 }#include  // cin\cout\endl
   ^
Main.cc: In function 'int main()':
Main.cc:25:5: error: redefinition of 'int main()'
 int main(){
     ^
Main.cc:7:5: note: 'int main()' previously defined here
 int main(){
     ^
Main.cc:36:13: error: expected '}' at end of input
     return 0;
             ^