Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-27-2008, 07:34 AM
Member
 
Join Date: Aug 2008
Posts: 15
kian_hong2000 is on a distinguished road
How to transpose a 2D array
From

1,2.3,4
5,6,7,8
9,10,11,12
13,14,15,16

To

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

Logic
1,2.3,4 (a+b+1)
5,6,7,8 (a+b+4)
9,10,11,12 (a+b+7)
13,14,15,16 (a+b+10)

Do i need to use any class?

Last edited by kian_hong2000 : 08-27-2008 at 07:43 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-27-2008, 08:47 AM
Fubarable's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 1,289
Fubarable is on a distinguished road
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!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array help please buzzdsm New To Java 3 06-19-2008 01:43 AM
Array Reflection: Multi Array Reflection Java Tip java.lang 0 04-23-2008 10:08 PM
can anyone help... 2d Array Mark1989 New To Java 2 03-12-2008 10:59 PM
Would appreciate your help with 2d Array.. cloudkicker New To Java 1 02-11-2008 04:34 PM
Help with Array susan New To Java 1 08-07-2007 06:32 AM


All times are GMT +3. The time now is 03:50 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org