|
-
Jul 7th, 2002, 10:30 AM
#1
Thread Starter
Frenzied Member
confusing multidimensional arrays
Heres a problem I came up with to try and explain my real problem:
Say I had a 5x5 grid of integers in an array (field[5][5]). The values are consecutive:
Code:
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
Now, since im trying to figure out what array element is what part in the grid, how would I output the number 6, 7, and 13, for example.
retired member. Thanks for everything 
-
Jul 7th, 2002, 07:47 PM
#2
Frenzied Member
Code:
const outputnumber = /* Insert your number here */
cout << field[outputnumber/5][outputnumber%5] << endl; //Ahh! Almost forgot the ";"!
Is this what you wanted?
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|