My code is failing in one test case, please help
Arrays spiral print (anticlockwise)
#include using namespace std; int main(){ int m,n; cin>>m>>n; int a[m][n]; for(int i=0; i<m; i++){ for(int j=0; j<n; j++){ cin>>a[i][j]; } } int startrow=0; int endrow=m-1; int startcol=0; int endcol=n-1; while( startcol<=endcol && startrow<=endrow){ for(int i=startrow; i<=endrow; i++){ cout<<a[i][startcol]<<", “; } startcol++; for(int i=startcol; i<=endcol; i++){ cout<<a[endrow][i]<<”, “; } endrow–; if(endcol>startcol){ for(int i=endrow; i>=startrow; i–){ cout<<a[i][endcol]<<”, “; } endcol–; } if(startrow<endrow){ for(int i=endcol; i>=startcol; i–){ cout<<a[startrow][i]<<”, "; } startrow++; } } cout<<“END”; return 0; }
Please provide your code in coding blocks IDE.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.