#include
using namespace std;
int main()
{
int n ,m;
cin>>m>>n;
int a[n][m];
if((m>=1 && m<=10)&&((n>=1 && n<=10)))
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>a[i][j];
}
}
for(int j=0;j<n;j=j+1)
{
if(j%2==0)
{
for(int i=0;i<m;i++)
{
cout<<a[i][j]<<","<<" “;
}
}
else
{
for(int i=m-1;i>=0;i–)
{
cout<<a[i][j]<<”,"<<" ";
}
}
}
}
cout<<“END”;
return 0;
}
Wrong test caes
Hey, @vishwash.bajpai87 the array should be of size M * N but you have taken array of size N * M that’s why you were getting wrong answer.
applying your method still i get the wrong output
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.