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
Expert's answer
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
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment