#include
using namespace std;
void spiralprint(int a[][10],int m,int n)
{
int start_row=0;
int end_row=m-1;
int start_col=0;
int end_col=n-1;
while(start_row <= end_row && start_col <= end_col)
{
for(int i=start_row;i<=end_row;i++)
{
cout<<a[i][start_col]<<", “;
}
start_col++;
for(int i=start_col;i<=end_col;i++)
{
cout<<a[end_row][i]<<”, “;
}
end_row–;
if(start_col < end_col)
{
for(int i=end_row;i>=start_row;i–)
{
cout<<a[i][end_col]<<”, “;
}
end_col–;
}
if(start_row < end_row)
{
for(int i=end_col;i>=start_col;i–)
{
cout<<a[start_row][i]<<”, ";
}
start_row++;
}
}
cout<<“END”;
}
int main() {
int m,n;
cin>>m>>n;
int a[10][10];
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>a[i][j];
}
}
spiralprint(a,m,n);
return 0;
}
this is my code and when i compiled it, gives correct answer.
But, when i submit it then it show wrong answer
i m unable to find my mistake
can u plzz help