回答編集履歴

1

追記

2022/01/08 06:14

投稿

episteme
episteme

スコア16612

test CHANGED
@@ -1,3 +1,67 @@
1
1
  × scanf("%lf", A[i*3+j]);
2
2
 
3
3
  ○ scanf("%lf", &A[i][j]);
4
+
5
+
6
+
7
+ [追記] それともやりたかったのはコレ↓か?
8
+
9
+ ```C
10
+
11
+ #include <stdio.h>
12
+
13
+ #include <stdlib.h>
14
+
15
+
16
+
17
+ int main(void) {
18
+
19
+
20
+
21
+ int i, j;
22
+
23
+ i = 3; j = 3; k = 3;
24
+
25
+ double* A = (double*)malloc(i*k*sizeof(double));
26
+
27
+ for (i = 0; i < 3; i++) {
28
+
29
+ for (j = 0; j < 3; j++) {
30
+
31
+ printf("A[%d][%d]=", i, j);
32
+
33
+ scanf("%lf", &A[i*k+j]);
34
+
35
+ }
36
+
37
+ }
38
+
39
+
40
+
41
+ double determinant;
42
+
43
+
44
+
45
+ determinant = A[0*k+0] * A[1*k+1] * A[2*k+2]
46
+
47
+ + A[0*k+1] * A[1*k+2] * A[2*k+0]
48
+
49
+ + A[0*k+2] * A[1*k+0] * A[2*k+1]
50
+
51
+ - A[0*k+0] * A[1*k+2] * A[2*k+1]
52
+
53
+ - A[0*k+1] * A[1*k+0] * A[2*k+2]
54
+
55
+ - A[0*k+2] * A[1*k+1] * A[2*k+0];
56
+
57
+
58
+
59
+ printf("determinant:%f\n", determinant);
60
+
61
+ free(A);
62
+
63
+ return 0;
64
+
65
+ }
66
+
67
+ ```