Unable to read values in line for 2d array

how to read values in 2 d arrays separated by both commas or new line

@Leepakshi-Yadav-2227257280820964 From the given sample case:
4 4
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44
You must point out that you have to print a column from top to bottom if it is an even column…and print column from bottom to top if it is an odd column. So print order would be like:
11, 21, 31, 41, 42, 32, 22, 12, 13, 23, 33, 43, 44, 34, 24, 14, END

Code for printing would be something like this:
for(int j=0;j<N;j++)
{
if(j%2==0){
for(int i=0;i<M;i++)
cout<<arr[i][j]<<", “;
}
else{
for(int i=M-1;i>=0;i–)
cout<<arr[i][j]<<”, ";
}
}
cout<<“END”;

Dry run it for the sample case if you face difficulty in understanding.
Hope this helps.

My question was that I am not able to take input with delimiter as space and endline

@Leepakshi-Yadav-2227257280820964 This can be done using STL string tokenizer function strtok. Lecture video of this is there in your course.But this is not required in this problem. You just have to access elements from the 2d array one by one and print it by separating it with , and an END at last.

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.