Experiment three arrays
First, the experimental purpose
1. Familiar with the structure of the array
2. Master the compressed storage of matrices
3. Ability to calculate compression storage of arrays and matrices
Second, the experiment content
1. If there is an element A [I-1 [J-1] in the matrix AM × n, it satisfies the minimum value in the first line element, and is the JR. The maximum element is called, the element is called a saddle point of the matrix. Use a two-dimensional array storage matrix AM × N, and the design algorithm is used to find all the saddle points in the matrix. (Folder: exercise 11_4)
/ * Array structure type definition .h * /
/ *
Const Int m = 3;
Const int N = 3;
* /
#define m 3
#define n 3
Typedef struct
{
INT A [M] [N];
/ * int MAX [M], min [n]; * / / * renv: I don't know what these two are doing * /
}
Array;
#include "Array Type Definition .h"
Void MinMax (Array * PA)
{
Int row, col;
Int temp;
ROW = 0, col = 0;
Printf ("Row / Tcol / TNumber: / N");
For (ROW = 0; ROW { COL = ROWMIN (PA-> A [ROW]); IF (row == colmax (PA-> A, COL)) { Printf ("% D / T% D / T% D / N", ROW, COL, PA-> A [ROW] [col]); } } Return; } Int rowmin (int P []) { INT J, COL; INT T = P [0]; COL = 0; For (j = 1; j { IF (p [j] { T = P [J]; COL = J; } } Return col; } INT colmax (int P [】 [n], int co) { INT I; Int row; Int temp; Row = 0; Temp = p [0] [col]; For (i = 1; i { IF (p [i] [col]> TEMP) { Temp = p [i] [col]; Row = i; } } Return row; } / * Looking for the main program file of the saddle point .cpp * / #include #include #include "Array Type Definition .h" int main () { / * Array * Pa = new arch; * / Array * Pa = (array *) malloc (archof (array)); INT I, J; Printf ("please input array [% d] [% d]: / n", m, n); For (i = 0; i For (j = 0; j / * CIN >> PA-> a [i] [j]; * / Scanf ("% D", & (PA-> A [i] [j])); MinMax (PA); System ("pause"); Return 0; }