/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Scanner teclado
= new Scanner
( System .
in ) ;
int ma[ ] [ ] = new int [ 3 ] [ 2 ] ;
int mb[ ] [ ] = new int [ 2 ] [ 2 ] ;
int mab[ ] [ ] = new int [ 3 ] [ 2 ] ;
for ( int i = 0 ; i < ma.length ; i++ ) {
for ( int j = 0 ; j < ma[ i] .length ; j++ ) {
System .
out .
println ( "Digite o elemento da linha " + ( i
+ 1 ) + " e coluna " + ( j
+ 1 ) + " da matriz 1" ) ; ma[ i] [ j] = teclado.nextInt ( ) ;
}
}
for ( int i = 0 ; i < mb.length ; i++ ) {
for ( int j = 0 ; j < mb[ i] .length ; j++ ) {
System .
out .
println ( "Digite o elemento da linha " + ( i
+ 1 ) + " e coluna " + ( j
+ 1 ) + " da matriz 2" ) ; mb[ i] [ j] = teclado.nextInt ( ) ;
}
}
for ( int i= 0 ; i< mab.length ; i++ ) {
for ( int j= 0 ; j< mab[ i] .length ; j++ ) {
for ( int k= 0 ; k< ma[ i] .length ; k++ ) {
mab[ i] [ j] += ma[ i] [ k] * mb[ k] [ j] ;
}
}
}
System .
out .
println ( "MultipliacaĆ§Ć£o das matrizes:" ) ;
for ( int i = 0 ; i < mab.length ; i++ ) {
for ( int j = 0 ; j < mab[ i] .length ; j++ ) {
System .
out .
print ( mab
[ i
] [ j
] + "\t " ) ; }
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0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