SlideShare uma empresa Scribd logo
1 de 2
1   package matriz;
 2   import java.util.*;
 3   import java.lang.System;
 4   import java.util.Scanner;
 5   public class Main
 6   {
 7       public static void main(String[] args)
 8           {
 9                   int i, j;
10                   Scanner Obj=new Scanner(System.in);
11                   int matriz [][]=new int[4][4];
12
13           matriz[0][0] = 2;
14           matriz[0][0] = 4;
15           matriz[0][1] = 5;
16           matriz[0][2] = 8;
17           matriz[0][3] = 4;
18           matriz[1][0] = 6;
19           matriz[1][1] = 4;
20           matriz[1][2] = 9;
21           matriz[1][3] = 6;
22           matriz[2][0] = 8;
23           matriz[2][1] = 10;
24           matriz[2][2] = 7;
25           matriz[2][3] = 9;
26           matriz[3][0] = 1;
27           matriz[3][1] = 3;
28           matriz[3][2] = 6;
29           matriz[3][3] = 5;
30
31               }
32           private int[][] elementos;
33       public Main gaussElim()
34       {
35               int nCols=4;
36               int nFilas=4;
37
38   Main resultado = this; // Empezamos con la matriz actual como resultado;
39       // no hay problema porque las operaciones de fila no modifican la original sino que devuelven matrices nuevas
40                   for (int j=0; j<nCols; j++) {
41                       for (int i=j+1; i<nFilas; i++) {
42                   resultado = resultado.anadeFila(i, j, -resultado.elementos[i][j] / resultado.elementos[j][j] );
43                       }
44                   }
45                   return resultado;
46       }
47
48
49       //System.out.println("La matriz superiror es: "+matriz[i][j]);
50
51       private Main anadeFila(int i, int j, int i0) {
52           throw new UnsupportedOperationException("Not yet implemented");
53       }
54
55   }

Mais conteúdo relacionado

Destaque

Pauta da reuniao de 26 de marco de 2013
Pauta da reuniao de 26 de marco de 2013Pauta da reuniao de 26 de marco de 2013
Pauta da reuniao de 26 de marco de 2013pibiduergsmontenegro
 
для партнеров рембт
для партнеров рембтдля партнеров рембт
для партнеров рембтikeaserv
 
In Value We Trust Or Not - Industry Report 3
In Value We Trust Or Not - Industry Report 3In Value We Trust Or Not - Industry Report 3
In Value We Trust Or Not - Industry Report 3Julia Chow
 
Atherosclerosis fact sheet.4.09
Atherosclerosis fact sheet.4.09Atherosclerosis fact sheet.4.09
Atherosclerosis fact sheet.4.09Hafsainam
 
Aquecimento Global
Aquecimento GlobalAquecimento Global
Aquecimento GlobalLuan Freitas
 
Demonstração que as pessoas conseguem tudo quando querem
Demonstração que as pessoas  conseguem tudo quando queremDemonstração que as pessoas  conseguem tudo quando querem
Demonstração que as pessoas conseguem tudo quando queremRoberto Rabat Chame
 
Magazine fount cover notes
Magazine fount cover notesMagazine fount cover notes
Magazine fount cover notesmason1
 
Opinion mining
Opinion miningOpinion mining
Opinion miningHa noi
 
الدرس السادس عشر
الدرس السادس عشرالدرس السادس عشر
الدرس السادس عشرAnas Aloklah
 
First example for data analysis
First example for data analysisFirst example for data analysis
First example for data analysisedac4co
 
Energias fosseis
 Energias fosseis Energias fosseis
Energias fosseisEspa Cn 8
 

Destaque (18)

Pauta da reuniao de 26 de marco de 2013
Pauta da reuniao de 26 de marco de 2013Pauta da reuniao de 26 de marco de 2013
Pauta da reuniao de 26 de marco de 2013
 
для партнеров рембт
для партнеров рембтдля партнеров рембт
для партнеров рембт
 
In Value We Trust Or Not - Industry Report 3
In Value We Trust Or Not - Industry Report 3In Value We Trust Or Not - Industry Report 3
In Value We Trust Or Not - Industry Report 3
 
Jour. 10 31
Jour. 10 31Jour. 10 31
Jour. 10 31
 
Atherosclerosis fact sheet.4.09
Atherosclerosis fact sheet.4.09Atherosclerosis fact sheet.4.09
Atherosclerosis fact sheet.4.09
 
Informe 89
Informe 89Informe 89
Informe 89
 
Calendar
CalendarCalendar
Calendar
 
Aquecimento Global
Aquecimento GlobalAquecimento Global
Aquecimento Global
 
Demonstração que as pessoas conseguem tudo quando querem
Demonstração que as pessoas  conseguem tudo quando queremDemonstração que as pessoas  conseguem tudo quando querem
Demonstração que as pessoas conseguem tudo quando querem
 
Biologia
BiologiaBiologia
Biologia
 
MyCl Flyed DL
MyCl Flyed DLMyCl Flyed DL
MyCl Flyed DL
 
Magazine fount cover notes
Magazine fount cover notesMagazine fount cover notes
Magazine fount cover notes
 
time value of money
time value of moneytime value of money
time value of money
 
Opinion mining
Opinion miningOpinion mining
Opinion mining
 
الدرس السادس عشر
الدرس السادس عشرالدرس السادس عشر
الدرس السادس عشر
 
First example for data analysis
First example for data analysisFirst example for data analysis
First example for data analysis
 
Los cuadriláteros
Los cuadriláterosLos cuadriláteros
Los cuadriláteros
 
Energias fosseis
 Energias fosseis Energias fosseis
Energias fosseis
 

Matriz Java Método Gauss Eliminação

  • 1. 1 package matriz; 2 import java.util.*; 3 import java.lang.System; 4 import java.util.Scanner; 5 public class Main 6 { 7 public static void main(String[] args) 8 { 9 int i, j; 10 Scanner Obj=new Scanner(System.in); 11 int matriz [][]=new int[4][4]; 12 13 matriz[0][0] = 2; 14 matriz[0][0] = 4; 15 matriz[0][1] = 5; 16 matriz[0][2] = 8; 17 matriz[0][3] = 4; 18 matriz[1][0] = 6; 19 matriz[1][1] = 4; 20 matriz[1][2] = 9; 21 matriz[1][3] = 6; 22 matriz[2][0] = 8; 23 matriz[2][1] = 10; 24 matriz[2][2] = 7; 25 matriz[2][3] = 9; 26 matriz[3][0] = 1; 27 matriz[3][1] = 3; 28 matriz[3][2] = 6; 29 matriz[3][3] = 5; 30 31 } 32 private int[][] elementos; 33 public Main gaussElim() 34 { 35 int nCols=4; 36 int nFilas=4; 37 38 Main resultado = this; // Empezamos con la matriz actual como resultado; 39 // no hay problema porque las operaciones de fila no modifican la original sino que devuelven matrices nuevas 40 for (int j=0; j<nCols; j++) { 41 for (int i=j+1; i<nFilas; i++) { 42 resultado = resultado.anadeFila(i, j, -resultado.elementos[i][j] / resultado.elementos[j][j] ); 43 } 44 } 45 return resultado;
  • 2. 46 } 47 48 49 //System.out.println("La matriz superiror es: "+matriz[i][j]); 50 51 private Main anadeFila(int i, int j, int i0) { 52 throw new UnsupportedOperationException("Not yet implemented"); 53 } 54 55 }