From 7d19bf22ad535547fd9dc0a74c6a2edf30631b84 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Fri, 3 Apr 2020 14:09:38 -0500 Subject: [PATCH 1/3] Update Array_Elecciones.java codigo java --- Array_Elecciones.java | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Array_Elecciones.java b/Array_Elecciones.java index 7a5585e..10e8e54 100644 --- a/Array_Elecciones.java +++ b/Array_Elecciones.java @@ -10,3 +10,43 @@ */ include Swing* + +/ * +Arreglos bidimensionales +mostrar en el área de texto solo los elementos de la primera fila + * / +paquete javaapplication1 ; + +import javax.swing. * ; + +/ ** + * * +* @autor UNISANGIL + * / + clase pública JavaApplication1 { + + Cadena estática salida = " " ; + / ** + * @param argumenta los argumentos de la línea de comando + * / + public static void main ( String [] args ) { + // TODO la lógica de aplicación del código aquí +int [] [] twoD = nuevo int [ 4 ] [ 4 ]; +twoD [ 0 ] [ 0 ] = 1 ; +twoD [ 0 ] [ 1 ] = 2 ; +twoD [ 0 ] [ 2 ] = 3 ; +dosD [ 0 ] [ 3 ] = 4 ; +twoD [ 1 ] [ 0 ] = 5 ; +twoD [ 1 ] [ 1 ] = 6 ; +twoD [ 1 ] [ 2 ] = 7 ; +twoD [ 1 ] [ 3 ] = 8 ; +Sistema . a cabo . print (twoD [ 0 ] [ 0 ] + " " ); +para ( int i = 0 ; i <= 3 ; i ++ ) { +salida = salida + twoD [ 0 ] [i] + " \ n " ; +} +JTextArea areaSalida = new JTextArea (); +areaSalida . agregar (salida); +// areaSalida.setText (salida); +JOptionPane . showMessageDialog ( nulo , areaSalida, " Suma de Matrices " , JOptionPane . INFORMACIÓN_ MENSAJE ); + } +} \ No newline at end of file From 0ca7e64851f41fc46a559c8b57519e7b82f5814c Mon Sep 17 00:00:00 2001 From: Gabriel Date: Fri, 3 Apr 2020 15:35:18 -0500 Subject: [PATCH 2/3] Update Array_Elecciones.java creacion de variables que le hicieron falta al contador --- Array_Elecciones.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Array_Elecciones.java b/Array_Elecciones.java index c18be85..b8756a7 100644 --- a/Array_Elecciones.java +++ b/Array_Elecciones.java @@ -22,8 +22,11 @@ public static void main(String args[]) { int SedeFila=6; int CandiColum=5; - - //Arreglos + int f; + int c; + String[] vecres = null; + + //Arreglos //array inicializado con 5 candidatos String Candidatos[]=new String[CandiColum]; From 04f73bd57afc63f78090618201d72523a3a948be Mon Sep 17 00:00:00 2001 From: Gabriel orjuela <62855805+gaot92@users.noreply.github.com> Date: Sun, 5 Apr 2020 21:14:53 -0500 Subject: [PATCH 3/3] Update Array_Elecciones.java .... --- Array_Elecciones.java | 71 ++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/Array_Elecciones.java b/Array_Elecciones.java index 5e1f6bb..056918f 100644 --- a/Array_Elecciones.java +++ b/Array_Elecciones.java @@ -12,8 +12,6 @@ correcion agregada - - import javax.swing.*; public class ArrayElecciones { @@ -21,11 +19,12 @@ public class ArrayElecciones { public static void main(String args[]) { + //ivan mauricio leal alvarez---------------- - // variables inicializadas + // Arreglos // matriz inicializado con 5 candidatos - String Candidatos [] = { " Juan" , " Pedro" ,"jesus","manuel","pepito" }; //AQUI YA ESTAN INICIALIZADO EL ARREGLO DE CANDIDATOS + String Candidatos [] = { " Juan" , " Pedro" ,"Jesus","Manuel","Ismael" }; // matriz inicializado con 29 sedes String SedeFila [] = { " APARTADO ", " ARMENIA "," BOGOTÀ "," BUCARAMANGA "," BUGA "," CALI "," CARTAGO "," CAUCASIA "," CUCUTA ", @@ -33,17 +32,18 @@ public static void main(String args[]) { " POPAYAN "," QUIBDO "," RIONEGRO "," SAHAGUN "," SINCELEJO "," SOGAMOSO "," TULUA "," TUMACO "," TUNJA "," VILLAVICENCO "," YOPAL "}; // matriz que almacena los votos - int[][] Votos; //AQUI YA ESTA DECLARA LA MATRIZ QUE HABIAN INICIALIZADO ABAJO - int []veces; - int numerom=0; - String casilla = null; - - //Votos = new int [5][6]; //NO ES NECESARIO INICIALIZAR LA MATRIZ + int Votos [][]; + int veces []; + + // variables inicializadas + int SedeFil=29; + int CandiColum=5; //------------John Fredy Bonilla----------------------- - // ingreso de votos + // ingreso de votos + Votos = new int[SedeFil][CandiColum]; for(int f=0 ; f< SedeFila.length ; f++){ for(int c=0 ; c< Candidatos.length;c++){ Votos[f][c] = Integer.parseInt(JOptionPane.showInputDialog("Porfavor ingrese la cantidad de votos que saco en la sede " @@ -52,46 +52,41 @@ public static void main(String args[]) { } //operacion suma por columnas - for(int f=0 ; f< SedeFila.length ; f++){ - for(int c=0; c< Candidatos.length;c++){ - veces[f]+=Votos[c][f]; - } - } + veces = new int[Candidatos.length]; + for (int y=0; yveces[f]){ - numerom = veces[0]; - casilla = Candidatos[f]; - }else{ - if(vecres[f]>numerom){ - numerom =vecres[f]; - casilla = Candidatos[f]; + int comparacion =0; + int cas=0; + + for (int i=0; i