One testcase is running and other is failing, please help
code:
#include<bits/stdc++.h>
using namespace std;
void spiralPrint(int arr[1000][1000],int row,int column)
{
int sr=0,sc=0,er=row-1,ec=column-1;
while(sr<=er and sc<=ec)
{
for(int col=sc;col<=ec;col++)
{
cout<<arr[sr][col]<<", ";
}
sr++;
for(int row=sr;row<=er;row++)
{
cout<<arr[row][ec]<<", ";
}
ec--;
for(int col=ec;col>=sc;col--)
{
cout<<arr[er][col]<<", ";
}
er--;
for(int row=er;row>=sr;row--)
{
cout<<arr[row][sc]<<", ";
}
sc++;
}
cout<<“END”;
}
int main(){
int arr[1000][1000];
int r,c;
cin>>r>>c;
int row=r,column=c;
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
cin>>arr[i][j];
}
cout<<endl;
}
spiralPrint(arr,r,c);
return 0;
}