質問編集履歴
3
追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -48,4 +48,6 @@
|
|
48
48
|
}
|
49
49
|
追記
|
50
50
|
指摘され部分を修正しました。
|
51
|
-

|
51
|
+

|
52
|
+
一応出力はされるようになったのですが→の列だけがうまく出力されなくなりました
|
53
|
+
配列で[0][1] [0][2] [0][3],[1][1] [1][2] [1][3],[2][1] [2][2] [2][3]に和を代入しているはずなのですが・・・
|
2
追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,48 +5,47 @@
|
|
5
5
|
|
6
6
|
#include<stdio.h>
|
7
7
|
#include<math.h>
|
8
|
-
|
8
|
+
#include <time.h>
|
9
|
+
#include <stdlib.h>
|
9
10
|
int main(void) {
|
10
|
-
|
11
|
+
int i, j = 1;
|
11
12
|
|
12
|
-
|
13
|
+
/* 行列 */
|
13
|
-
|
14
|
+
int a[10][10], b[10][10]; double c[10][10];
|
14
15
|
|
15
|
-
|
16
|
+
printf("\n1つ目の行列 A を入力\n");
|
16
|
-
|
17
|
+
for (i = 0; i < 3; ++i) {
|
17
|
-
|
18
|
-
scanf("\n%d %d %d", &a[i][j], &a[i][j+1], &a[i][j+2]);
|
19
|
-
|
20
|
-
|
21
|
-
}
|
22
18
|
|
23
|
-
|
19
|
+
scanf("\n%d %d %d", &a[i][j], &a[i][j + 1], &a[i][j + 2]);
|
24
|
-
for (i = 0; i < 3; ++i) {
|
25
20
|
|
26
|
-
|
21
|
+
}
|
27
|
-
|
28
22
|
|
29
|
-
}
|
30
|
-
j = 1;
|
31
|
-
|
23
|
+
printf("\n2つ目の行列 B を入力\n");
|
32
|
-
|
24
|
+
for (i = 0; i < 3; ++i) {
|
33
|
-
for (j = 1; j < 3; ++j) {
|
34
|
-
c[i][j] = 0;
|
35
|
-
}
|
36
|
-
}
|
37
|
-
for (i = 0; i < 3; ++i) {
|
38
|
-
for (j = 1; j < 3; ++j) {
|
39
|
-
c[i][j] = a[i][j] + b[i][j];
|
40
|
-
}
|
41
|
-
}
|
42
25
|
|
43
|
-
printf("\n行列 C = A + B\n");
|
44
|
-
for (i = 0; i < 3; ++i) {
|
45
|
-
|
26
|
+
scanf("\n%d %d %d", &b[i][j], &b[i][j + 1], &b[i][j + 2]);
|
46
|
-
}
|
47
27
|
|
28
|
+
}
|
29
|
+
j = 1;
|
30
|
+
/* 行列の和(足し算) */
|
31
|
+
for (i = 0; i < 3; ++i) {
|
32
|
+
for (j = 1; j < 3; ++j) {
|
33
|
+
c[i][j] = 0;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
for (i = 0; i < 3; ++i) {
|
37
|
+
for (j = 1; j < 3; ++j) {
|
38
|
+
c[i][j] = a[i][j] + b[i][j];
|
39
|
+
}
|
40
|
+
}
|
41
|
+
j = 1;
|
42
|
+
printf("\n行列 C = A + B\n");
|
43
|
+
for (i = 0; i < 3; ++i) {
|
44
|
+
printf("\n%lf %lf %lf ", c[i][j], c[i][j + 1], c[i][j + 2]);
|
45
|
+
}
|
46
|
+
|
48
|
-
|
47
|
+
return 0;
|
49
48
|
}
|
50
49
|
追記
|
51
|
-
|
50
|
+
指摘され部分を修正しました。
|
52
|
-

|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -46,4 +46,7 @@
|
|
46
46
|
}
|
47
47
|
|
48
48
|
return 0;
|
49
|
-
}
|
49
|
+
}
|
50
|
+
追記
|
51
|
+
実行結果です
|
52
|
+

|