output not show correct on this site while on coding block ide it show correct
Not working right output
ok
#include
using namespace std;
int main()
{
int N=0,M=0;
int count=0;
cin>>M>>N;
int a[M][N]={{0}};
///input is getting from user in 2-D array
for(int i=0;i<M;i++){
for(int j=0;j<N;j++)
{
cin>>a[i][j];
}
}
int j=0;
while(count<N){
///Wave extract the column-wise
for(int i=0;i<M;i++)
{
///extract the even column
if(j%2==0)
{
cout<<a[i][j]<<",";
}
///extract the odd column
else
{
cout<<a[M-i-1][j]<<",";
}
}
j+=1;
count+=1;
}
cout<<“END”;
return(0);
}
Hi @dheeraj_961
You are making error in printing as you have to print space between next array element and comma.
Here is your corrected code :
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.