/* Create a cross-linked list for the non-collar elements of the input matrix and print the complete program of the Cross-linked list in row mode */
Struct matnode/* cross linked list node definition */
{
Int row, col;
Struct matnode * right, * down;
Union {
Int val;
Struct matnode * next;
} Tag;
};
Struct matnode * createmat ()
{
Int m, n, t, s, I, r, c, v;
Struct matnode * h [100], * p, * q;/* h [] is the array of header pointers for each row in the cross linked list */
Printf ("number of rows m, number of columns n, number of non-zero elements t :");
Scanf ("% d, % d, % d", & m, & n, & t );
P = (struct matnode *) malloc (sizeof (struct matnode ));
H [0] = p;
P-> row = m;
P-> col = n;
S = m> n? M: n;
For (I = 1; I <= s; I ++)
{
P = (struct matnode *) malloc (sizeof (struct matnode ));
H [I] = p;
H [I-1]-> tag. next = p;
P-> row = p-> col = 0;
P-> down = p-> right = p;
}
H [s]-> tag. next = h [0];
For (I = 1; I <= t; I ++)/* t indicates the number of non-zero elements */
{
Printf ("t % d element (row number m, column number n, value v):", I );
Scanf ("% d, % d, % d", & r, & c, & v );
P = (struct matnode *) malloc (sizeof (struct matnode ));
P-> row = r;
P-> col = c;
P-> tag. val = v;
Q = h [r];
While (q-> right! = H [r] & q-> right-> col <c)
Q = q-> right;
P-> right = q-> right;
Q-> right = p;
Q = h [c];
While (q-> down! = H [c] & q-> down-> row <r)
Q = q-> down;
P-> down = q-> down;
}
Return (h [0]);
}