Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Ejercicio2;
- import java.io.IOException;
- public class Matriz12 {
- private int[][]clase1;
- private int nf;
- private int nc;
- static final int NF=2;
- static final int NC=5;
- Matriz12()
- {
- clase1=new int[NF][NC];
- }
- Matriz12(int pnf,int pnc)
- {
- nf=pnf;
- nc=pnc;
- }
- public void cargarporfilas() throws IOException
- {
- int num,i,j;
- for(i =0;i<clase1.length;i++)
- {
- for(j=0;j<clase1[i].length;j++)
- {
- System.out.println("Introduzca numeros");
- num = Consola.leeInt();
- clase1[i][j]=num;
- }
- }
- }
- public void cargarporColumnas() throws IOException
- {
- int num,i,j;
- for(j =0;j<clase1[0].length;j++)
- {
- for(i=0;i<clase1.length;i++)
- {
- System.out.println("Introduzca numeros");
- num = Consola.leeInt();
- clase1[i][j]=num;
- }
- }
- }
- public void ver()
- {
- int i,j;
- for(i=0;i<clase1.length;i++)
- {
- for(j=0;j<clase1[i].length;j++)
- {
- System.out.print(clase1[i][j]+ " ");
- }
- System.out.println();
- }
- }
- public void invertirFilas() throws IOException
- {
- int i,j,k,cont;
- for(i=0;i<clase1.length;i++)
- {
- cont=1;
- for(j=0;j<clase1[i].length-cont;j++)
- {
- k=clase1[i][j];
- clase1[i][j]=clase1[i][clase1[i].length-cont];
- clase1[i][clase1[i].length-cont]=k;
- cont++;
- }
- }
- }
- public boolean intercambiarFilas(int nf1, int nf2)
- {
- int []aux =null;
- if(nf1<clase1.length & nf2<clase1.length)
- aux=clase1[nf1-1];
- clase1[nf1-1]=clase1[nf2-1];
- clase1[nf2-1]=aux;
- return false;
- }
- // public static int []Mayorfila // parametros array de una fila
- /*
- int j,i,imax;
- int max=-999;
- for(int i=0; i<Asignaturas.length;i++)
- {
- int suma=0;
- for (j=0; j<Asignaturas[i].length;j++){
- suma+=Asignaturas M [i] [j]
- }
- media=Suma/Asignaturas[i].length
- }
- if (media>max) {
- max=media
- imax=1;
- }
- int []dev=Asignaturas[max];
- return Asignaturas[imax];
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment