Can anyone please tell me where i gone wrong .
Here’s my code.
#include
using namespace std;
int main() {
int m , n ;
cin>>m>>n;
int a[10][10];
int startrow =0 , startcol=0 , endrow=m-1 , endcol=n-1;
for(int i=0 ; i<m ; i++){
for(int j=0 ; j<m ; j++){
cin>>a[i][j];
}
}
while(startrow<endcol && startcol<endcol){
//orint first col
for(int i=startrow ; i<=endrow ; i++){
cout<<a[i][startcol]<<", ";
}
startcol++;
//print last row
if(endrow>startrow){
for(int i=startcol ; i<=endcol ; i++){
cout<<a[endrow][i]<<", ";
}
endrow--;
}
//print last col
if(endcol>startcol){
for(int i=endrow ; i>=startrow ; i--){
cout<<a[i][endcol]<<", ";
}
endcol--;
}
//print first row
for(int i=endcol ; i>=startcol ; i--){
cout<<a[startrow][i]<<", ";
}
startrow++;
}
cout<<"END";
return 0;
}