#include
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int k=0,l=0;
int mat[n][m];
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cin>>mat[i][j];
}
for(int x=0;x<n*m;x++)
{
cout<<mat[k++][l]<<", ";
if(k-1==n-1)
{
k=0;l=l+1;
}
}
cout<<"END"<<endl;
return 0;
}
input:
4 4
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44
output:
11, 21, 31, 41, 42, 32, 22, 12, 13, 23, 33, 43, 44, 34, 24, 14, END
what’s wrong with the code,it was only able to pass one testcase