Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
150073 孔声豪 求序列的前n项和 C++ Compile Error 0 MS 0 KB 239 2026-03-22 10:38:07

Tests(0/0):


Code:

#include<iostream> using namespace std; int main(){ double a=1,b=2;c; int n,sum=0,i; cin>>n; for(i=1;i<=n;i++){ sum+=a/b; c=a; a=a+b; b=c; } cout<<sum<<endl; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:4:19: error: 'c' was not declared in this scope
    double a=1,b=2;c;
                   ^