#include
using namespace std;
void spiral(int n,int m, int arr[][m]){
int sr=0;
int sc=0;
int er=n-1;
int ec=m-1;
while(sr<=er&& 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 >=0; col--)
{
cout<<arr[er][col]<<' ';
}
er--;
for ( int row = er; row >= sr; row--)
{
cout<<arr[row][ec]<<' ';
}
sc++;
}
}
int main()
{
int n,m;
cin>>n>>m;
int arr[n][m];
int val=1;
for (int row = 0; row < n; ++row)
{
for (int col = 0; col < m; ++col)
{
cout<<val<<’ ';
val++;
}
cout<<endl;
}
spiral(n,m,arr[n][m]);
return 0;
// not able to understand the mistake