pls check my code ,test case failing
All fpur test cases failing samle test case is correct
#include
using namespace std;
int main() {
int n,m;
cin>>n>>m;
int input[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>input[i][j];
}
}
bool b=true;
for(int i=0;i<n;i++){
int j;
if(b){
j=0;
b=false;
for(;j<m;j++){
cout<<input[j][i]<<" “;
}
continue;
}
else{
b=true;
j=m-1;
for(;j>=0;j–){
cout<<input[j][i]<<” ";
}
}
}
cout<<"END"<<" ";
return 0;
}
hi @kartikmadan26 ,
your code is failing for odd test cases like
3 4
11 12 13 14
21 22 23 24
31 32 33 34
you can debug yourself now
OR
here’s your updated and simplified code https://ide.codingblocks.com/s/658368 I’ve commented
hope this helps
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.