wojiaocbj

C5-E cbj

Mar 30th, 2023
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <ctype.h>
  6. #include <time.h>
  7. long long mat[4][4] = { 0 }, submat[3][3] = { 0 };
  8. void copy(int x, int y){
  9.     int i, j, p = 0, q;
  10.     for(i = 0; i < 4; i++){
  11.         if(i == x){
  12.             continue;
  13.         }
  14.         q = 0;
  15.         for(j = 0; j < 4; j++){
  16.             if(j == y){
  17.                 continue;
  18.             }
  19.             submat[p][q] = mat[i][j];
  20.             q++;
  21.         }
  22.         p++;
  23.     }
  24. }
  25. long long det3(){
  26.     return ((submat[0][0] * submat[1][1] * submat[2][2]) + (submat[1][0] * submat[2][1] * submat[0][2]) + (submat[2][0] * submat[0][1] * submat[1][2])) - ((submat[2][0] * submat[1][1] * submat[0][2]) + (submat[1][0] * submat[0][1] * submat[2][2]) + (submat[0][0] * submat[2][1] * submat[1][2]));
  27. }
  28. int main(){
  29.     int i, j;
  30.     for(i = 0; i < 4; i++){
  31.         for(j = 0; j < 4; j++){
  32.             scanf("%lld", &(mat[i][j]));
  33.         }
  34.     }
  35.     copy(0, 1);//M1,2
  36.     printf("%lld\n", det3());
  37.     copy(3, 2);//M4,3
  38.     printf("%lld\n", det3());
  39.     copy(2, 2);//M3,3
  40.     printf("%lld\n", det3());
  41.     copy(0, 3);//M1,4
  42.     printf("%lld\n", det3());
  43.     copy(1, 3);//M2,4
  44.     printf("%lld\n", det3());
  45.     copy(2, 2);//M3,3
  46.     printf("%lld\n", det3());
  47.     copy(1, 1);//M2,2
  48.     printf("%lld\n", det3());
  49.     copy(3, 0);//M4,1
  50.     printf("%lld\n", det3());
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment