/*
* 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 matrizhori {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
Scanner sn = new Scanner (new File ("in3.txt"));
FileOutputStream fos = new FileOutputStream ("out3.txt");
PrintStream ps = new PrintStream (fos);
int n = sn.nextInt();
int matriz [ ] [ ] = new int [n] [n];
for(int i=0;i<=n-1;i++){
for (int j=0;j<=n-1;j++){
matriz [i] [j] = sn.nextInt();
System.out.print(matriz [i] [j] + " " );
ps.print(matriz [i] [j] + " " );
}
System.out.println();
ps.println();
}
for(int i=0;i<=n-1;i++){
int suma = 0;
for (int j=0;j<=n-1;j++){
suma= suma + matriz [i] [j];
}
System.out.println( );
System.out.print(suma + " ");
ps.print(suma + " ");
}
// TODO code application logic here
//suma de columnas horizontalmente
}
}
No hay comentarios:
Publicar un comentario