Arrays-wave print column wise

#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%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;

}
sir why this code is showing wrong answer in each test cases here
although it is giving correct output in code blocks

I have edited the code, plz refer to it, only issue was in printing with spaces, rest code was fine.

thank you for the help