Postingan lainnya
Perkalian Matriks Java C++ Pascal
Apa yang ada bisa membantu membuatkan Algoritma perkalian matriks 3x3?
0
Tanggapan
Pertanyaannya yang tepat mungkin bukan algoritma, tapi source codenya, karena algortima perkaliannya ya ada di pelajaran matematika SMA
1 Jawaban:
Jawaban Terpilih
<pre>
public class tc {
public static void main(String... Randomly) {
// declaration and initialization multi dimensional arrays
int[][] a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int[][] b = {{9, 8, 7}, {6, 5, 4}, {3, 2, 1}};
int[][] c = new int[3][3];
// multiplication of two arrays
int i = 0;
for (; i &lt; 3;) {
int j = 0;
do {
int k = 0;
do {
c[i][j] = c[i][j] + a[i][k] * b[k][j];
k = k + 1;
} while (k &lt; 3);
j += 1;
} while (j &lt; 3);
i = i + 1;
}
// print out the result
i = 0;
do {
int j = 0;
for (; j &lt; 3;) {
System.out.print(c[i][j]);
System.out.print("\t");
j += 1;
}
System.out.print("\n");
i = i + 1;
} while (i &lt; 3);
}
}
</pre>
itu gan versi java ane, monggo dipahami dulu hhee,.....
0