Results 1 to 2 of 2
Thread: How to transpose a 2D array
- 08-27-2008, 05:34 AM #1Member
- Join Date
- Aug 2008
- Rep Power
How to transpose a 2D array
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
Is it more easy to use 1D array than 2D array to transpose?
I know that i use for loop as below it will display every row from 0 to 3,
but how to put in the expression in the for loop so that i can apply the logic inside?
for(int a = 0; a < 4; a++)
for(int b = 0; b < 4; b++)
group [a][b] = a + b +1;
I know that to dislay the result below i must
Do i need to use any class?
Last edited by kian_hong2000; 08-27-2008 at 05:43 AM.
Yes, this is the "2D" forum, but here 2D stands for 2-dimensional graphics, usually problems involving the Graphics2D class. Your question should have been posted in the beginner's forum.
That said, to solve your problem, why not create a second array, a pair of nested for loops, and copy items from one array at a time? You should try to work out the details on your own (by trying and failing and then ultimately succeeding, you'll learn more than by our just giving you the answer). Good luck!
- By buzzdsm in forum New To JavaReplies: 3Last Post: 06-18-2008, 11:43 PM
- By Java Tip in forum java.langReplies: 0Last Post: 04-23-2008, 08:08 PM
- By Mark1989 in forum New To JavaReplies: 2Last Post: 03-12-2008, 08:59 PM
- By cloudkicker in forum New To JavaReplies: 1Last Post: 02-11-2008, 02:34 PM
- By susan in forum New To JavaReplies: 1Last Post: 08-07-2007, 04:32 AM