Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
119771 罗子童 22第n项的数 C++ Compile Error 0 MS 0 KB 535 2025-05-18 19:05:51

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 main(){ int n,B1,B2,m; cin>>n; int a[n+1] for(int i=0;i<=n+1;i++){ cin>>a[i]; } B1=n[1]-n[0]; B2=n[2]-n[1]; if(B1==B2){ m=a[0]+(n-1)*(a[1]-a[0]); } else{ m=a[0]*pow(a[1]/a[0],n-1); } return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:10:5: error: expected initializer before 'for'
     for(int i=0;i<=n+1;i++){
     ^
Main.cc:10:17: error: 'i' was not declared in this scope
     for(int i=0;i<=n+1;i++){
                 ^
Main.cc:13:11: error: invalid types 'int[int]' for array subscript
     B1=n[1]-n[0];
           ^
Main.cc:13:16: error: invalid types 'int[int]' for array subscript
     B1=n[1]-n[0];
                ^
Main.cc:14:11: error: invalid types 'int[int]' for array subscript
     B2=n[2]-n[1];
           ^
Main.cc:14:16: error: invalid types 'int[int]' for array subscript
     B2=n[2]-n[1];
                ^
Main.cc:16:11: error: 'a' was not declared in this scope
         m=a[0]+(n-1)*(a[1]-a[0]);     
           ^
Main.cc:19:11: error: 'a' was not declared in this scope
         m=a[0]*pow(a[1]/a[0],n-1);
           ^