Programming Practice
In some applications, matrices are sparsed, instead of dense. A form of sparse matrix is triangular matrices, as the following figure:
A is a lower triangular matrix with all elements above the diagonal being 0's, B is an upper triangular matrix with all elements below the diagonal being 0's, and C=A´B. Write a C program to input an integer r of square matrix size for matrices A, B, and C. Use dynamic memory allocation to create exact space for triangular matrices A, B, and C and randomly generate element ai,j, for i³j, and bi,j, for i£j, for lower triangular matrix A and upper triangular matrix B, respectively. Then, compute matrix multiplication C=A´B. Output matrices A, B, and C; do not print the upper triangle elements for matrix A and lower triangle elements for matrix B.
Program execution example: