• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in code

 
aditya miduthuru
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can we write a code for transpose of a matrix with only one array and that too for non-symmetric array???
Help me up we are trying to do in c but not able write a logic
 
Praveen Kumar M K
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well considering that you have an array(which in actuality is an array of arrays) you want to write a program to convert from Ain to Aout on the same array. Hope I got that right.

Ain =
[
1 2 3
4 5 6
]

Aout =
[
1 4
2 5
3 6
]

It is not possible either in C or in Java to convert a 2x3 array to 3x2. A single array's dimensions and capacity are fixed during compile time and you cannot change that programmatically.

You can take an input array, create an output array(with dimensions switched) and then iterate and fill the output array.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12084
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest you work it out by hand first. Write down the directions, in English (or any other natural language), that a 10 year old child can understand. Once you have that, writing the code is a lot simpler.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic