I am unable to find the correct logic and the compile time error in foloowing code.The code is not saving on IDE
#include
#include
using namespace std;
bool alreadyVisited(int a[][10],int r,int c){
if(a[r][c]==1)
return true;
return false;
}
void funkyMove(int a[][10],int r,int c,int n){
if(r>=n||c>=n||a[r][c]==0)
return ;
if(!alreadyVisited(a[][c],r,c)){
a[r][c]=2;
return ;
}
else
{
return ;
}
funkyMove(a[][10],r-2,c-1,n);
funkyMove(a[][10],r-2,c+1,n);
funkyMove(a[][10],r-1,c-2,n);
funkyMove(a[][10],r-1,c+2,n);
funkyMove(a[][10],r+1,c-2,n);
funkyMove(a[][10],r+1,c+2,n);
funkyMove(a[][10],r+2,c-1,n);
funkyMove(a[][10],r+2,c+1,n);
}
int main() {
int n;
cin>>n;
int arr[10][10];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
a[i][j]=0;
int r=0,c=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>a[i][j];
int ulc=0;//upper left corner flag
for(int i=0;i<n;i++)
{ for(int j=0;j<n;j++)
if(a[i][j]==1){
r=i;
c=j;
ulc=1;
break;
}
if(ulc==1)
break;
}
funkyMove(a[r][c],r,c,n);
int flag=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
if(a[i][j]==1)
flag++;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
return 0;
}