Language: C++

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<string.h>
using namespace std;
struct DDD{
int x,y,c;
};
int main(){
while(1)
int i,j,n,m,p[92][92]={0},ans=0,xm[4]={1,-1,0,0},ym[4]={0,0,1,-1},l;
DDD d;
stack<DDD> zect;
scanf("%d%d",&m,&n);
if(n==0&&m==0)break;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++)scanf("%d",&p[i][j]);
}
for(i=1;i<=n;i++){
	for(j=1;j<=m;j++){
		if(p[i][j]==1){
			int up[92][92];
			memset(up,0x7f,sizeof(up));
			d.x=i;
			d.y=j;
			d.c=1;
			zect.push(d);
			while(!zect.empty()){
				d=zect.top();
				up[d.x][d.y]=d.c;
				zect.pop();
				ans=max(d.c,ans);
				for(l=0;l<4;l++){
					if(p[d.x+xm[l]][d.y+ym[l]]==1&&up[d.x+xm[l]][d.y+ym[l]]>=d.c){
						d.x+=xm[l];
						d.y+=ym[l];
						d.c++;
						up[d.x][d.y]=d.c;
						zect.push(d);
						d.x-=xm[l];
						d.y-=ym[l];
						d.c--;
					}
				}
				
			}
		}
	}
}
printf("%d\n",ans);
}
return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:15:15: error: 'm' was not declared in this scope
   15 | scanf("%d%d",&m,&n);
      |               ^
a.cc:15:18: error: 'n' was not declared in this scope
   15 | scanf("%d%d",&m,&n);
      |                  ^
a.cc:16:15: error: break statement not within loop or switch
   16 | if(n==0&&m==0)break;
      |               ^~~~~
a.cc:17:5: error: 'i' was not declared in this scope
   17 | for(i=1;i<=n;i++){
      |     ^
a.cc:18:5: error: 'j' was not declared in this scope
   18 | for(j=1;j<=m;j++)scanf("%d",&p[i][j]);
      |     ^
a.cc:18:30: error: 'p' was not declared in this scope
   18 | for(j=1;j<=m;j++)scanf("%d",&p[i][j]);
      |                              ^
a.cc:20:5: error: 'i' was not declared in this scope
   20 | for(i=1;i<=n;i++){
      |     ^
a.cc:21:13: error: 'j' was not declared in this scope
   21 |         for(j=1;j<=m;j++){
      |             ^
a.cc:22:20: error: 'p' was not declared in this scope
   22 |                 if(p[i][j]==1){
      |                    ^
a.cc:33:33: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |                                 ans=max(d.c,ans);
      |                                 ^~~
      |                                 abs
a.cc:34:37: error: 'l' was not declared in this scope
   34 |                                 for(l=0;l<4;l++){
      |                                     ^
a.cc:35:50: error: 'xm' was not declared in this scope; did you mean 'tm'?
   35 |                                         if(p[d.x+xm[l]][d.y+ym[l]]==1&&up[d.x+xm[l]][d.y+ym[l]]>=d.c){
      |                                                  ^~
      |                                                  tm
a.cc:35:61: error: 'ym' was not declared in this scope; did you mean 'tm'?
   35 |                                         if(p[d.x+xm[l]][d.y+ym[l]]==1&&up[d.x+xm[l]][d.y+ym[l]]>=d.c){
      |                                                             ^~
      |                                                             tm
a.cc:51:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   51 | printf("%d\n",ans);
      |               ^~~
      |               abs
a.cc: At global scope:
a.cc:53:1: error: expected unqualified-id before 'return'
   53 | return 0;
      | ^~~~~~
a.cc:54:1: error: expected declaration before '}' token
   54 | }
      | ^