107 284
Assignments Done
97.9%
Successfully Done
In March 2023

# Answer to Question #7297 in C++ for Jason

Question #7297
Hi, I need to find a solution or way to do this: I read ints from a txt by pairs.
(e.g: row 1 = 2,1 row 2 = 6,6 (including comma)) then I add them to a bi-dimensional matrix[N][2], how could I later, extract that numbers in a way that the 1st four numbers can be placed each on a variable?,
e.g int x1 = matrix[0][0] , int y1 = matrix[0][1] , int x2 = matrix[1][0], int y2 [1][1];
so my problem is given that original bi-array assign x1,y1,x2,y2 to the 1st 4 numbers, then to the next 4 numbers,after that to the next 4 numbers, etc... I'm working on c++.
1
2012-03-15T10:01:20-0400
As we understand you want to assign variables (x1 y1 , x2 y2) with every four consecutive numbers from bi-dimensional matrix[N][2]. Here is the
solution:

//code starts here
int x1;
int y1;

int x2;
int y2;
// loop which you are interested in
for (int i = 0; i < N; i += 2)
{
//first row
x1 = matrix[i][0];
y1 = matrix[i][1];
//second row
x2 = matrix[i+1][0];
y2 = matrix[i+1][1];
}
//code ends here

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!