#include
#include
using namespace std;
int wave(int arr[][1000],int i, int j)
{
int col,row;
for(col=0;col<i;col++){
if(col%2==0){
for(row=0;row<j;row++){
cout<<arr[row][col]<<",";
}
}
else{
for(row=j-1;row>=0;row–){
cout<<arr[row][col]<<",";
}
}
}
return 0;
}
int main()
{
int n,i,j;
int a[1000][1000];
int m;
cin>>n>>m;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
cin>>a[i][j];
}
}
wave(a,n,m);
}
How to add “END” at the end of this.