Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
110571 郭玉洁 12奇数和与偶数和 C++ Compile Error 0 MS 0 KB 297 2025-02-22 12:36:52

Tests(0/0):


Code:

//重复代码统一化,注意i的结束条件 //构建for循环 //做两个小变动 #include<bits/stdc++.h> using namespace std; int main() { int sam=0; int m=0 for(int i=1;i<=12;i++){ if(i%2!=0){ sam=sam+i; } } for(int i=1;i<=12;i++){ if(i%2=0){ m=m+i; } } cout<<m;


Run Info:

Main.cc: In function 'int main()':
Main.cc:9:1: error: expected ',' or ';' before 'for'
 for(int i=1;i<=12;i++){
 ^
Main.cc:9:13: error: 'i' was not declared in this scope
 for(int i=1;i<=12;i++){
             ^
Main.cc:15:8: error: lvalue required as left operand of assignment
  if(i%2=0){
        ^
Main.cc:7:5: warning: unused variable 'sam' [-Wunused-variable]
 int sam=0;
     ^
Main.cc:19:8: error: expected '}' at end of input
 cout<