Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
113863 罗子童 函数求和 C++ Compile Error 0 MS 0 KB 457 2025-03-16 19:04:37

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 sum(int a,int b){ int s=0 for(int i=a;i<=b;i++){ s+=i; } return s; } int main(){ int x,y; cout<<sum(1,10)<<endl<<sum(20,30)<<endl<<sum(35,45)<<endl; return 0; }


Run Info:

Main.cc: In function 'int sum(int, int)':
Main.cc:8:5: error: expected ',' or ';' before 'for'
     for(int i=a;i<=b;i++){
     ^
Main.cc:8:17: error: 'i' was not declared in this scope
     for(int i=a;i<=b;i++){
                 ^
Main.cc: In function 'int main()':
Main.cc:14:9: warning: unused variable 'x' [-Wunused-variable]
     int x,y;
         ^
Main.cc:14:11: warning: unused variable 'y' [-Wunused-variable]
     int x,y;
           ^