aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt in code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "doubt in code" Watch "doubt in code" New topic

doubt in code

aditya miduthuru

Joined: Nov 28, 2012
Posts: 1
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

Joined: Jul 03, 2011
Posts: 256
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

Joined: Oct 02, 2003
Posts: 11575

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.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Consider Paul's rocket mass heater.
subject: doubt in code