|
|
|
|
|
|
|
Figure 13-4 hiTemp Array (Third Variation) |
|
|
|
|
|
|
|
|
enum Colors {RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET};
enum Makes
{
FORD, TOYOTA, HYUNDAI, JAGUAR, CITROEN, BMW, FIAT, SAAB
};
const int NUM_COLORS = 7;
const int NUM_MAKES = 8;
float crashRating[NUM_COLORS][NUM_MAKES]; // Array of crash
// likelihoods by color
// and make
.
.
.
crashRating[BLUE][JAGUAR] = 0.83; // Blue Jaguars have a crash
// likelihood of 0.83
crashRating[RED][FORD] = 0.19; // Red Fords have a crash
// likelihood of 0.19 |
|
|
|
|
|
|
|
|
the data structure uses one dimension to represent the color and the other to represent the make of automobile. In other words, both indices have semantic contenta concept we discussed in Chapter 11. |
|
|
|
|
|
|
|
|
Processing Two-Dimensional Arrays |
|
|
|
|
|
|
|
|
Processing data in a two-dimensional array generally means accessing the array in one of four patterns: randomly, along rows, along columns, or throughout the entire array. Each of these may also involve subarray processing. |
|
|
|
|
|