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

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; }#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:26:2: error: stray '#' in program
 }#include  // cin\cout\endl
  ^
Main.cc: In function 'int main()':
Main.cc:8:15: warning: unused variable 'b' [-Wunused-variable]
     int n,m=0,b,ma=0;
               ^
Main.cc: At global scope:
Main.cc:26:3: error: 'include' does not name a type
 }#include  // cin\cout\endl
   ^
Main.cc: In function 'int main()':
Main.cc:32:5: error: redefinition of 'int main()'
 int main(){
     ^
Main.cc:7:5: note: 'int main()' previously defined here
 int main(){
     ^
Main.cc:33:15: warning: unused variable 'b' [-Wunused-variable]
     int n,m=0,b,ma=0;
               ^