|
|
 |
|
|
|
|
monthlyHigh = 0;
for (logger = 0; logger < NUM_LOGGERS; logger++)
if (logsCut[logger][2] >> monthlyHigh)
{
bestLogger = logger;
monthlyHigh = logsCut[logger][2];
} |
|
|
|
 |
|
|
|
|
d. The following statements would find the logger with the highest monthly production and the logger's best month. (True or False?) |
|
|
|
 |
|
|
|
|
high = -1;
for (month = 0; month < 12; month++)
for (logger = 0; logger < NUM_LOGGERS; logger++)
if (logsCut[logger][month] >> high)
{
high = logsCut[logger] [month];
bestLogger = logger;
bestMonth = month;
} |
|
|
|
|
|
|
|
|
9. Declare the float array variables described below. Use proper style. |
|
|
|
 |
|
|
|
|
a. A three-dimensional array where the first dimension is indexed from 0 through 9, the second dimension is indexed by an enumeration type representing the days of the week, and the third dimension is indexed from 0 through 20. |
|
|
|
 |
|
|
|
|
b. A four-dimensional array where the first two dimensions are indexed from 0 through 49, and the third and fourth are indexed by any valid ASCII character. |
|
|
|
|
|
|
|
|
Programming Warm-Up Exercises |
|
|
|
|
|
|
|
|
1. Write a C++ value-returning function that returns TRUE if all the values in a certain subarray of a two-dimensional array are positive, and returns FALSE otherwise. The array (of type TableType), the number of columns in the subarray, and the number of rows in the subarray should be passed as parameters. |
|
|
|
|
|
|
|
|
2. A square array is a two-dimensional array in which the number of rows is the same as the number of columns. Write a C++ function to initialize the two diagonals of a square char array to a specified character. The array (named data, of type the row and column lengths of the array (length), and the specified character (someChar) should be passed as parameters. |
|
|
|
|
|
|
|
|
3. Write a C++ function Copy that takes an array data, defined to be NUM_ROWS by NUM_COLS, and copies the values into a second array data2, defined the same way. data and data2 are of type DataType. The constants NUM_ROWS and NUM_COLS may be accessed globally. |
|
|
|
|
|
|
|
|
4. Write a C++ function that finds the largest value in a two-dimensional float array of 50 rows and 50 columns. |
|
|
|
|
|
|
|
|
5. Using the declarations in Exam Preparation Exercise 1, write functions to do the following tasks. Use proper style. Only constants may be accessed globally. |
|
|
|
 |
|
|
|
|
a. Determine the team that sold the most tickets during the first week of ticket sales. |
|
|
|
|
|