I seem to be brain-farting today. I have an array matrix I'm trying to implement and could use some advice, please.
Here's basically an example of data I have:
Level
1 2 3 4 5 6 7 8 9 10
--------------------------------------
Skill 5 | 6 2 3 3 9 1 1 1 6 8
10 | 6 1 1 8 5 7 2 3 7 3
15 | 4 4 2 8 6 5 4 7 9 9
20 | 8 3 3 8 7 3 6 7 9 1
25 | 9 2 4 1 9 6 8 9 8 3
30 | 2 1 5 1 9 2 1 1 8 3
35 | 2 1 6 1 8 7 2 1 9 8
40 | 1 4 7 4 8 8 2 1 9 7
45 | 1 8 8 4 9 8 2 3 4 6
50 | 3 8 9 3 9 2 1 5 3 5
|
I'd like to build a few arrays (perhaps multi-dimensional?) to pull the numbers I need.
Example of how this is to be used:
If a person of level 6 has a skill of 20, I want to return the number "3".
If a person of level 9 has a skill of 45, I want to return the number "4".
etc...
So, given the two constants (level and skill), how can I design an array to hold the return values, and return them as needed?
Here's what I have so far:
1 2 3 4 5
|
const int MAX_MATRIX = 11;
struct Skill_Matrix {
int level[MAX_MATRIX];
int skill[MAX_MATRIX];
};
|
Now, there are 100 different possibilities (10 x 10). Granted, I *could* do something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
const int MAX_MATRIX = 11;
struct Skill_Matrix {
int level[MAX_MATRIX];
int skill_5[MAX_MATRIX];
int skill_10[MAX_MATRIX];
int skill_15[MAX_MATRIX];
int skill_20[MAX_MATRIX];
int skill_25[MAX_MATRIX];
int skill_30[MAX_MATRIX];
int skill_35[MAX_MATRIX];
int skill_40[MAX_MATRIX];
int skill_45[MAX_MATRIX];
int skill_50[MAX_MATRIX];
};
|
... and then do something like,
person.skill == 25 ? Skill_Matrix.skill_25[person.level]:null;
... but that doesn't seem very efficient. Again, I only want to pull the values needed. The arrays would be stuffed with the data elsewhere.
Suggestions are welcome. Thanks!