you have two arry and you want to replace the column of one of them to the row of another?
replacement column and row between two arrays?
Collapse
X
-
Tags: None
-
Read this: http://bytes.com/topic/c/insights/77...rrays-revealed
Pay particular attention to the section on how arrays are laid out in memory.
Then post again if you still have a question. -
To do this I think the two arrays would need to be the same size and square. If you're not fussy about which row and column the following shows how you would go about this using one 4x4 2d array to interchange row2 and column2. Using two arrays follows the same principle.
To change column2 into row2:
swap element [0][1] with element [1][0]
swap element [2][1] with element [1][2]
swap element [3][1] with element [1][3]
(element [1][1] is not moved as it is common to the column & row)Comment
-
@whodgson:
You would not use an array. Instead you would use a structure lke a chain-link table where the columns can be of unequal length.
A chain-link table is a linked list where each node is itself a linked list. Replacement here is to delete the linked list at one node and replce it with another linked list There is no requirement that the two linked lists involved have the same number of nodes.Comment
-
to:weaknessforc ats. yes i am pretty weak on lists so will need to dig a bit. The PO (or is it OP) in this case specified that he/she had two arrays and simply wanted to swap a row in one with a column in the other. but I understand in principle what you are telling me and appreciate it.Comment
Comment