Wave print column wise

Output is correct but it does show wrong answer while submiting.

Share it code so we can debug it

#include
using namespace std;
int main() {
long long int M,N;
cin >> M >> N;
long long int arr[20][20];
for(long long int i=0;i<M;i++)
{
for(long long int j=0;j<N;j++)
{
cin >> arr[i][j];
}
}
for(long long int j=0;j<N;j++)
{
if(j&1)
{
for(long long int i=M-1;i>=0;i–)
{
cout << arr[i][j]<<", β€œ;
}
}
else
{
for(long long int i=0;i<N;i++)
{
cout << arr[i][j]<<”, ";
}
}
}
cout << β€œEND”<<endl;
}

save ur code to online ide of coding block and then post the link here it will help in debugging

in line 25 i<M
and u have write i<N
this is the error

1 Like

thanx alot, I got it !!!