Wave print test cases

code :
#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];
}
}
for(int i = 0; i < n; i++)
{
if(i & 1)
{
for(int j = m-1; j >= 0; j–)
{
cout<<a[j][i]<<",";
}

    }
    else
    {
        for(int j = 0; j < m; j++)
        {
             cout<<a[j][i]<<",";
        }
    }
}
cout<<"END";
return 0;

}
above is my code for wave print although it’s matching with the test cases shown in e.g but is unable to find any test case plealse suggest some test cases

@Divya_321 hey divya this is because you are missing the space between the number after comma fix that it will pass the test cases.

1 Like

I am getting runtime error this time;
#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];
}

}

for(int j = 0; j < n; j++)
{
	if(j & 1)
	{
		for(int i = m -1; m >= 0; i--)
		{
			cout<<a[i][j]<<", ";
		}
	}
	else
	{
		for(int i = 0; i < m; i++)
			cout<<a[i][j]<<", ";

	}
}
cout<<"END";

return 0;
}

can’t I copy paste code from my personal ide to the ide provided to us

@Divya_321 hey divya I think your second loop should be
for(int i = m - 1 ; i > = 0 ; i - - )