Answer not coming

logic is right

#include
using namespace std;
int main() {
int m,n,i,a[10][10],j;
cin>>m>>n;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>a[i][j];

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

}

share your code using ide.codingblocks.com so that I can help you.

#include

using namespace std;

int main() {

int m,n,i,a[10][10],j;

cin>>m>>n;

for(i=0;i<m;i++)

{

    for(j=0;j<n;j++)

    {

        cin>>a[i][j];

    }

}

for(i=0;i<m;i++)

{

    if(i%2==0)

    {

        for(j=0;j<n;j++)

        {

            cout<<a[j][i]<<",";

        }

    }

    else

    {

        for(j=n-1;j>=0;j--)

        cout<<a[j][i]<<",";

    }

}

cout<<"END";

return 0;

}

How to share code using ide.codingblocks.com?

  • go to ide.codingblocks.com
  • paste ur code
  • press ctrl+s
  • click on save
  • share your code by sending url

https://ide.codingblocks.com/s/376648 (you can share your code by sharing url like this)

You won’t pass test case cause the logic you have used is not right
for
INPUT:
2 3
1 2 3
4 5 6
Expected output is:
1, 4, 5, 2, 3, 6, END
Your’s is giving:
1, 4, 1256996272, 21909, 5, 2, END

Have debugged your code with logic here


And it will give you full marks as well.