Lab KI21-30
Three-Dimensional Array
15 points
ELT 215
| Below is some partial code for
the primary loop of a program that will display elements from a
three-dimensional array. This array has 2 rows and 3 columns, and
inside each "slot" specified by a row and a column, there are 4
elements (numbers). A function in our library called TDArray will get a particular element from a three-dimensional array. We need to send a row number, column number, and element number to the TDArray function. Once TDArray has gotten a number from the array, we send it to DispFP, which will display the number in the alphanumeric display. Your job is to write code that will do the following:
|
| /* Switches 7 and 6 select the row. Switches 3 and 2 select the column. Switches 1 and 0 select the element. | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |<=== Row ===>| |<==== Col ==>|<== Element=>| */ row = Put switches 7 and 6 into row column = Put switches 3 and 2 into column. element = Put switches 1 and 0 into element. //If "row" is too large, display "Error" and keep getting //numbers from switches 7 and 6 until "row" contains a number //that's OK. while (row > 1) { Error(); row = Put switches 7 and 6 into row } //If "column" is too large, display "Error" and keep getting //numbers from switches 3 and 2 until "column" contains a //number that's OK. while ( ) { } //If "element" is too large, display "Error" and keep getting //numbers from switches 1 and 0 until "element" contains a //number that's OK. while ( ) { } number = TDArray(row, column, element, XARRAY); DispFP(number, 0); |