Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
154476 蔡皓霆 12奇数和与偶数和 C++ Compile Error 0 MS 0 KB 470 2026-05-30 14:21:02

Tests(0/0):


Code:

#include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; for(int i=m;i<=;i++) int even_sum = 0; // 偶数和 int odd_sum = 0; // 奇数和 // 遍历区间 [m, n] for (int i = m; i <= n; i++) { if (i % 2 == 0) { even_sum += i; } else { odd_sum += i; } } cout << even_sum << " " << odd_sum; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:8:20: error: expected primary-expression before ';' token
     for(int i=m;i<=;i++)
                    ^
Main.cc:9:9: warning: unused variable 'even_sum' [-Wunused-variable]
     int even_sum = 0;  // 偶数和
         ^
Main.cc:17:13: error: 'even_sum' was not declared in this scope
             even_sum += i;
             ^
Main.cc:25:13: error: 'even_sum' was not declared in this scope
     cout << even_sum << " " << odd_sum;
             ^