-
Notifications
You must be signed in to change notification settings - Fork 0
/
tugas6_soal2 matriks 3d.cpp
82 lines (67 loc) · 1.96 KB
/
tugas6_soal2 matriks 3d.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
int main(){
int matriks3d_3[2][3][5];
cout<<"\n\t ---------- Program Penjumlahan Matriks 3D ----------\n\n";
cout<< "Matriks A : \n\n";
int matriks3d_1[2][3][5] =
{
{
{11, 12, 13, 14, 15}, //baris 1
{16, 17, 18, 19, 20}, //baris 2
{21, 22, 23, 24, 25} //baris 3
},
{
{26, 27, 28, 29, 30}, //baris 1
{31, 32, 33, 34, 35}, //baris 2
{36, 37, 38, 39, 40} //baris 3
}
};
for( int x=0; x<2; x++){
for( int y=0; y<3; y++){
for( int z=0; z<5; z++){
cout<<matriks3d_1[x][y][z]<<" ";
}cout<<endl;
}cout<<endl;
}cout<<endl;
cout<<endl;
cout<< "Matriks B : \n\n";
int matriks3d_2[2][3][5] =
{
{
{110, 120, 130, 140, 150}, //baris 1
{160, 170, 180, 190, 200}, //baris 2
{210, 220, 230, 240, 250} //baris 3
},
{
{260, 270, 280, 290, 300}, //baris 1
{310, 320, 330, 340, 350}, //baris 2
{360, 370, 380, 390, 400} //baris 3
}
};
for( int x=0; x<2; x++){
for( int y=0; y<3; y++){
for( int z=0; z<5; z++){
cout<<matriks3d_2[x][y][z]<<" ";
}cout<<endl;
}cout<<endl;
}cout<<endl;
cout<<"==========================================="<<endl;
cout<<"\n\nHasil Penjumlahan Matriks A dan Matriks B : \n\n";
for( int x=0; x<2; x++){
for( int y=0; y<3; y++){
for( int z=0; z<5; z++){
matriks3d_3[x][y][z] = matriks3d_1[x][y][z] + matriks3d_2[x][y][z];
}
}
};
for( int x=0; x<2; x++){
for( int y=0; y<3; y++){
for( int z=0; z<5; z++){
cout<<matriks3d_3[x][y][z]<<" " ;
}cout<<endl;
}cout<<endl;
}cout<<endl;
}