Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
93925 只因你太美(Ikun 真爱粉) 22相差2的数的个数 C++ Compile Error 0 MS 0 KB 618 2024-10-19 15:35:16

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() #include<string> using namespace std; int main(){ int n,m=0,b,ma=0; cin>>n; int a[n] for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=1;i<n;i++){ if(a[i]>=a[i-1]&&a[i]-a[i-1]<=2){ m++;} else if(a[i]<a[i-1]&&a[i-1]-a[i]<=2){ m++;} else{ ma=max(ma,m);m=0 } } cout<<ma; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:11:5: error: expected initializer before 'for'
     for(int i=0;i=a[i-1]&&a[i]-a[i-1]<=2){
            ^
Main.cc:22:9: error: expected ';' before '}' token
         }
         ^
Main.cc:8:15: warning: unused variable 'b' [-Wunused-variable]
     int n,m=0,b,ma=0;
               ^