Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
100757 谭思宸 13奇数和与偶数和 C++ Compile Error 0 MS 0 KB 318 2024-12-12 20:22:00

Tests(0/0):


Code:

#include<iostream> using namespace std; int main() { long long n,sum1=0,sum2=0 cin>>n; for(int i=1;,j=2;j<=n;i+=2,j+=2) { sum1+=i; sum2+=j; } if(n%2!=0) sum1+=n; cout<<sum1<<" "<<sum2<<endl; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:6:8: error: expected ',' or ';' before 'cin'
        cin>>n;
        ^
Main.cc:7:20: error: expected primary-expression before ',' token
        for(int i=1;,j=2;j<=n;i+=2,j+=2)
                    ^
Main.cc:7:21: error: 'j' was not declared in this scope
        for(int i=1;,j=2;j<=n;i+=2,j+=2)
                     ^
Main.cc:7:29: error: expected ')' before ';' token
        for(int i=1;,j=2;j<=n;i+=2,j+=2)
                             ^
Main.cc:7:16: warning: unused variable 'i' [-Wunused-variable]
        for(int i=1;,j=2;j<=n;i+=2,j+=2)
                ^
Main.cc:7:30: error: 'i' was not declared in this scope
        for(int i=1;,j=2;j<=n;i+=2,j+=2)
                              ^
Main.cc:7:35: error: 'j' was not declared in this scope
        for(int i=1;,j=2;j<=n;i+=2,j+=2)
                                   ^