Public class MatrixMultiplication
Public static void main(String[] args) {
MatrixMultiplication i = new MatrixMultiplication();
i.start();
}
private void start() {
Matrix A = new Matrix();
Matrix B = new Matrix ();
Matrix C - new Matrix() ;
int N = readN();
B.napelnij (N);
C.napelnij(N);
A.pomnoz(B,C);
System.out.println(”Wynik = ”);
A.wyswietl(N);
}
public int readN() {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Int z =0;
Try{
String s - br.readLine();
Z = Integer.parseInt(s);
}
catch(Exception ex) {
}
return z;
TA KLASA JEST SZABLONEM DLA RESZTY MACIERZY
import
public class Matrix {
private int [] [] tab b ;
public int readWartosc(){() {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Int z =0;
Try{
String s - br.readLine();
Z = Integer.parseInt(s);
}
catch(Exception ex) {
}
return z;
}
public void napelnij (int N) {
tab b = new int [N] [N];
for (int i=0;i<N;i++) {
for (int j=0;j<N;j++) {
System.out.println(“Podaj wartość macierzy”);
Tab[i][j]=readWartość();
}
}
}
public void pomnoz(Matrix B, Matrix C,int N) {
tab = new int [N][N];
for (int i=0;i<N;i++) {
for (int j=0;j<N;j++) {
tab[i][j]=0;
for (int k=0;k<N;k++) {
tab[i][j] += B.dajElement(i,k)*C.dajElement(k,j);
}
}
}
public int daj Element(int i, int j) {
return tab [i][j];
}
public void int wyswietl(int N) {
for (int i=0;i<N;i++) {
for (int j=0;j<N;j++) {
System.out.println (”Wartosc ” + i + ” ” +j +”+tab[i][j]);
}
}
}