![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
octobersky
Joined: 21 Jun 2005 Posts: 3
|
Lookup Table |
Posted: Wed Nov 30, 2005 2:29 pm |
|
|
12 combinations of 3 items from a group of six.
items: apple, pear, grape, plumb, orange, and tomato
combination 0: apple, pear, plumb
combination 1: apple, plumb, orange
..
each item has three different properties
apple = {20.1, 25.2, 30.3}
pear = {10.0, 12.5, 17.5}
..
I'm trying to write a function in C that will access one property of an item
given the combination number and item index. For example:
lookup(1,0,2) would return 30.3 or second combination, first item, third property.
I don't really know where to start |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 30, 2005 3:46 pm |
|
|
Use a three dimensional array. |
|
![](templates/subSilver/images/spacer.gif) |
octobersky
Joined: 21 Jun 2005 Posts: 3
|
3D Array |
Posted: Wed Nov 30, 2005 4:13 pm |
|
|
2D (2x3)
Code: |
int grid[3][2] = { {10,20},{30,40},{50,60} };
/* The table of grid looks like
* ---------
* 0| 10 | 20 |
* 1| 30 | 40 |
* 2| 50 | 60 |
* ---------
* 0 1
*
*/
|
{ {x1y1,x2y1}, {x1y2,x2y2}, {x1y3,x2y3} }
3D (2x3x2)
Does z build out of the page?
{ {x1y1z1,x2y1z1}, {x1y2z1,x2y2z1}, {x1y3z1,x2y3z1},
{x1y1z2,x2y1z2}, {x1y2z2,x2y2z2}, {x1y3z2,x2y3z2} }
grid [1][0][1] = x1y2z2? |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|