why the other two cases are not getting passed???
Wave print column wise
Pls send your code by saving on ide so that I could check itβ¦
1 Like
thank you
i got the error
#include
using namespace std;
void spiral(int a[][1000],int m,int n){
int sr=0;
int sc=0;
int ec=n-1;
int er=m-1;
int count=0;
int total=m*n;
while(er>=sr and ec>=sc){
if (count == total){
break;
}
for(int i=sr;i<=er;i++){
cout<<a[i][sc]<<", ";
count++;
}
sc++;
if (count == total){
break;
}
for(int i=sc;i<=ec;i++){
cout<<a[er][i]<<", ";
count++;
}
er--;
if (count == total){
break;
}
if(ec>=sc){
for(int i=er;i>=sr;i--){
cout<<a[i][ec]<<", ";
count++;
}
ec--;}
if (count == total){
break;
}
if(er>=sr){
for(int i=ec;i>=sc;i--){
cout<<a[sr][i]<<", ";
count++;
}
sr++;}
}
cout<<βENDβ;
}
int main(){
int a[1000][1000]={0};
int m,n;
cin>>m>>n;
int val=11;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>a[i][j];
}
}
spiral(a,m,n);
}
final solution