how can we extract rows from a 2D array?
for example :
let us say we have 2D array of size 5x3
1 1 1
2 3 1
1 2 3
1 0 5
7 0 2
I have to search for the row which contains elements 1 2 3
how can I do this ?
how can we extract rows from a 2D array?
for example :
let us say we have 2D array of size 5x3
1 1 1
2 3 1
1 2 3
1 0 5
7 0 2
I have to search for the row which contains elements 1 2 3
how can I do this ?
See I’ll help you to understand it in a better way. Suppose horizontal lines are row and vertical lines are column.
So your question is that which row has elements 1 2 & 3 . And answer for that is row 2, which is 2 3 1
So how can you find that is, iterate on each row using for loop
For(int I=0;I<n;I++){
____For(int j=0;j<n;j++){
______// check if a[i][j] in this row of I, has 1,2&3 in it or not
______//if not then check in next ith row
____}
}
I hope this would help you as I have explained it in a very simple way
I try this
In this, I try to take one entire row at a time and print it
Hey @aattuull see this code
https://ide.codingblocks.com/s/355622
I have added few comments for your better understanding
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.