/* Paste your code here (You may delete these lines if not writing code) */
void spiralmatrix(int arr[], int m, int n)
{
int rowstart=0, rowend=m-1, colstart=0, colend=n-1;
int i,j;
while(rowstart<=rowend&&colstart<=colend)
{
int i=rowstart, j=colstart;
for(j=colstart;j<=colend;j++)
{
printf("%d",arr[i][j]);
}
for(i=rowstart+1,j--;i<=rowend;i++)
{
printf("%d",arr[i][j]);
}
for(j=colend-1,i--;j>=colstart;j--)
{
printf("%d",arr[i][j]);
}
for(i=rowend-1,j++;i>=rowstart+1;i--)
{
printf("%d",arr[i][j]);
}
rowstart++, rowend--, colstart++,colend--;
}
}