domingo, 24 de agosto de 2014

TALLER MATRICEZ

CODIGO 

Paquete matrizuno;

/ **
 *
 * Autor LEONARDO
 * /
public class Matrizuno {

   (String [] args) {public void 
 definitiva int FILAS = 3; 
 definitiva int COLUMNAS = 5; 
 Char LETRAS [] [] = new char [FILAS] [COLUMNAS]; 
 'A' Char letraQueToca =; 
 // Carga de Las Letras en La Matriz 
 for (int f = 0; f <FILAS; f ++) { 
 for (int c = 0, c <COLUMNAS; c ++) { 
 letras [f] [c] = letraQueToca; 
 letraQueToca ++; 
 } 
 } 
 // Mostrar en Pantalla La Matriz 
 for (int f = 0; f <FILAS; f ++) { 
 for (int c = 0, c <COLUMNAS; c ++) { 
 System.out.print (letras [f] [c] + ""); 
 } 
 System.out.println (); 
 } 
}
    
}

CODIGO # 2

matrizdos Paquete;
/ **
 *
 * Autor LEONARDO
 * /
public class Matrizudos {

(String [] args) {public void 
 definitiva int TAM = 5; 
 charlas triangulo [] [] = new char [TAM] [TAM]; 
 // Cargar Matriz Con el dibujo 
 for (int f = 0; f <TAM; f ++) { 
 // Bucle Parr mostrar Espacios 
 for (int c = 0, c <f, c ++) 
 triangulo [f] [c] = ''; 
 // Bucle Parr mostrar asteriscos 
 for (int c = f; c <TAM; c ++) 
 triangulo [f] [c] = '*'; 
 } 
 // Mostrar Matriz en Pantalla 
 for (int f = 0; f <TAM; f ++) { 
 for (int c = 0, c <TAM; c ++) 
 System.out.print (triangulo [f] [c]); 
 System.out.println (); 
 } 
    
}

CODIGO # 3

empaquetar media1;
 
importar java.util. *; 
javax.swing.JOptionPane importación;
public class Media1 { 
 (String [] args) {public void 
 int i; 
 int pos = 0, neg = 0; 
 int [] numeros = new int [10]; 
 sumaPos dobles = 0.0, sumaNeg = 0.0;
 Entrada Cadena;
 System.out.println ("Lectura de los Elementos del array:"); 
 for (i = 0; i <10; i ++) 
 { 
 fotos Entrada = JOptionPane.showInputDialog ("numeros [" + i + "] ="); 
 numeros [i] = Integer.parseInt (Entrada); 
 } 
 for (i = 0; i <10; i ++) { 
 if (numeros [i]> 0) { 
 sumaPos + = numeros [i]; 
 pos ++; 
 } Else if (numeros [i] <0) { 
 sumaNeg + = numeros [i]; 
 neg ++; 
 } 
 } 
 if (pos! = 0) { 
 System.out.println ("Medios de Los Valores Positivos:" + sumaPos / 
pos); 
 } Else { 
 System.out.println ("No hay numeros ha introducido Positivos"); 
 } 
 if (neg! = 0) { 
 System.out.println ("Medios de Los Valores Negativos:" + sumaNeg / 
neg); 
 } Else { 
 System.out.println ("No hay numeros ha introducido Negativos"); 
 } 
 } 


NOS PERMITE ingresar DATOS TIPO DE CUERDAS CONVERTIRLOS A TIPO ENTERO Y OPERARLOS PARA LA MEDIA DE Obtener NUMEROS POSITIVOS Y Negativos.

CODIGO # 4

empaquetar Multiplicacion;
/ **
 *
 *author LEONARDO
 * /
java.util.Scanner importación; 
 public class Multiplicacion
 { 
static void main (String args []) públicos
 // Sí se Quiere Multiplicar matrices de Distinta dimensión 
 // Solitario change Que Hay los Valores de M, N y P 
 private int M = 3; 
 private int N = 2; 
 int P privados = 4; 
 private int Matriz1 [] [] = new int [N] [M]; 
 private int Matriz2 [] [] = new int [M] [P]; 
 private int Matriz3 [] [] = new int [N] [P]; 
 Entrada escáner = new escáner (System.in); 

 System.out.printf ("Este Programa Multiplica Una Matriz de" + M + "Columnas y" + N + "Renglones"); 
 System.out.printf ("con uña de% d Columnas y% d Renglones \ n \ n", P, M); 
 System.out.print ("\ Naqui sí reciben Las Entradas de la Primera Matriz"); 
 System.out.printf (". De% d Filas y Columnas% d \ n", M, N);

 for (int i = 0; i <N; i ++)
 { 
for (int j = 0; j <M; j ++)
 System.out.printf ("Introduzca el valor de la post in el renglón% dy La Columna% d:", i + 1, j + 1); 
 Matriz1 [i] [j] = entrada.nextInt (); 
 } // Cierra para 
 System.out.printf ("\ Naqui sí reciben Las Entradas de la Segunda Matriz"); 
 System.out.printf ("de% d Filas y Columnas% d", M, P); 

for (int i = 0; i <M; i ++) 
 for (int j = 0; j <P; j ++) 
 {// Abre para 
 System.out.printf ("\ nIntroduzca el valor en el renglón% dy La Columna% d:", i + 1, j + 1); 
 Matriz2 [i] [j] = entrada.nextInt (); 
 } // Cierra para 
 for (int k = 0; k <N; k ++)
 {// Abre Primer Ciclo de 
 for (int j = 0; j <P; j ++) 
 {// Abre el Ciclo Segundo para 
 for (int i = 0; i <M; i ++) Matriz3 [k] [j] = + Matriz1 [k] [i] * Matriz2 [i] [j]; 
 } // Cierra el Ciclo Segundo para 
 } 
 System.out.printf ("\ n \ Naqui SE IMPRIMEN LAS DOS MATRICES Y EL PRODUCTO: \ n \ n"); 

 for (int i = 0; i <N; i ++) 
 { 
 for (int k = 0; k <M; k ++) 
 {// Abre Ciclo de 
 System.out.printf ("% 3d", Matriz1 [i] [k]); 
 // Se imprime el renglón i de la Matriz 1 
 } // Cierra Ciclo de 
 System.out.printf ("\ t \ t"); // This Instrucción Separa Una Matriz de Otra 
 // Este Ciclo imprime La Segunda Matriz 
 for (int j = 0; j <P; j ++) 
 {// Abre para 
 if (i <= (N - 1)) System.out.printf ("% 3d", Matriz2 [i] [j]); // Sí imprime el renglón i de la Matriz 2 
 else // De lo contrario solo sí imprimen 3 Espacios en Blanco 
 // Correspondientes estafa 3d 
    System.out.printf (""); 
 } // Cierra para 
 System.out.printf ("\ t \ t"); // This Instrucción Separa La Matriz 2 de la Matriz 
 // Producto 
 // Este es el Ciclo Que imprime La Matriz Producto 
 for (int j = 0; j <P; j ++) 
 {// Abre para 
 System.out.printf ("% 3d", Matriz3 [i] [j]); 
 // Sí imprime el renglón i de la Matriz Producto 
 } // Cierra para 
 System.out.printf ("\ n"); 
 // Aqui sí Cambia de renglón 
 // Cierra del Que Controla, Número de Renglones 
 // Es probable Que N> M, Por lo Cual es el Ciclo anterior no sí 
 // Imprimiria La Segunda Matriz en do totalidad 
 // Con el siguiente bloque en sí imprime Que lo Falta 
 if (M> N) 
 {// Abre si 
 int l = N; 
 while (l <M) 
 {// Abre mientras 
 for (i = 0; i <M; i ++) 
 System.out.printf (""); 
 System.out.printf ("\ t \ t \ t"); 
 for (int j = 0; j <P; j ++) 
 System.out.printf ("% 3d", Matriz2 [l] [j]); 
 System.out.printf ("\ n"); // Aqui sí Cambia de linea 
 l ++; // Se Incrementa el numero de linea 
 } // Cierra mientras 
 } // Cierra si 
 }
 } // Cierra el clase Multiplicacion 

PRETENDE OPERAR MATRICEZ DE DIFERENTES DIMESIONES.
PRESENTA ERRORES EN EL PRIMER PRIVATE INT M, LOS PRINTF Y EN ALGUNOS FOR NO LOS PUDE CORREGIR.






No hay comentarios:

Publicar un comentario