The exercises in this chapter are classic:
3-4 Unit Matrix
5. Matrix Multiplication
8. Eight queens
Among them, I feel that there is a problem with the eight queens problem. If I do not use the Backtracking Method well, I will not go down first.
Please see http://download.csdn.net/download/wangpegasus/5701765
3,
bool identity_matrix(int matrix[10][10]){int length = 10;for (int i = 0; i < length; i++){for (int j = 0; j < length; j++){if (i==j){if (matrix[i][j] != 1){return false;}else{continue;}}else{if(matrix[i][j] != 0){return false;}else{continue;}}}}}
4,
bool identity_matrix(int *matrix, int n){int length = n;for (int i = 0; i < length; i++){for (int j = 0; j < length; j++){if (i==j){if (*matrix++ != 1){return false;}else{continue;}}else{if(*matrix++ != 0){return false;}else{continue;}}}}}
5,
void matrix_multiply(int *m1, int *m2, int *r, int x, int y, int z){for(int i = 0; i < x; i++){for (int j = 0; j < y; j++){for (int k = 0; k < z; k++){*(r + i + i*k) += *(m1 + i + i*j) * (*(m2 + j + j*k)); }}}}
C and pointer (pointers on C) -- Chapter 8: array (ii) exercises