jueves, 9 de diciembre de 2010

multiplicacion 2a * 3b

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package matriz;
import java.io.*;
import java.util.*;

/**
*
* @author xxx
*/
public class matriz2a3b {
public static void main(String[] args) throws FileNotFoundException, IOException {

Scanner sn = new Scanner (new File ("in2.txt"));
FileOutputStream fos = new FileOutputStream ("out2.txt");
PrintStream ps = new PrintStream (fos);

int n = sn.nextInt();
int a [ ] [ ] = new int [n] [n];
int b [ ] [ ] = new int [n] [n];
int c [ ] [ ] = new int [n] [n];

for (int i=0;i<=n-1;i++){
for (int j=0;j<=n-1;j++){
a [i] [j] = sn.nextInt();

}
}
for (int i=0;i<=n-1;i++){
for (int j=0;j<=n-1;j++){
b [i] [j] = sn.nextInt();
}
}

for (int i=0;i<=n-1;i++){
for (int j=0;j<=n-1;j++){

c [i] [j]=0;
c [i] [j]= (2* a [i] [j]) - (3 * b [i] [j]);
System.out.print(c [i] [j]+ " ");
ps.print(c [i] [j]+ " ");
}
System.out.println();
ps.println();
}
}
}

//multiplicacion 2a * 3b

No hay comentarios:

Publicar un comentario