0% found this document useful (0 votes)
23 views5 pages

Taller 3 Info II

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views5 pages

Taller 3 Info II

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIVERSIDAD PEDAGÓGICA NACIONAL

JUAN PABLO DÍAZ VANEGAS

LIC. DISEÑO TECNOLÓGICO

INFORMATICA II

PROFESOR: NICOLAS GARCIA DONCEL

2023-1
Desarrollo del taller:
import java.util.Scanner;

public class MultiplicacionArreglos {


public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] A = new int[10];
int[] B = new int[10];

System.out.println("Ingrese los elementos del arreglo


A:");
for (int i = 0; i < 10; i++) {
A[i] = input.nextInt();
}

System.out.println("Ingrese los elementos del arreglo


B:");
for (int i = 0; i < 10; i++) {
B[i] = input.nextInt();
}

int producto = 0;
for (int i = 0; i < 10; i++) {
producto += A[i] * B[i];
}
System.out.println("El producto de A x B es: " +
producto);
}
}

2. Suma de matrices

import java.util.Scanner;

public class SumaMatrices {


public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[][] matrizA = new int[5][5];
int[][] matrizB = new int[5][5];
int[][] matrizC = new int[5][5];

System.out.println("Ingrese los elementos de la matriz


A:");
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
matrizA[i][j] = input.nextInt();
}
}

System.out.println("Ingrese los elementos de la matriz


B:");
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
matrizB[i][j] = input.nextInt();
}
}

for (int i = 0; i < 5; i++) {


for (int j = 0; j < 5; j++) {
matrizC[i][j] = matrizA[i][j] + matrizB[i][j];
}
}

System.out.println("Matriz A:");
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
System.out.print(matrizA[i][j] + " ");
}
System.out.println();
}

System.out.println("Matriz B:");
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
System.out.print(matrizB[i][j] + " ");
}
System.out.println();
}

System.out.println("Matriz C (resultado de la suma):");


for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
System.out.print(matrizC[i][j] + " ");
}
System.out.println();
}
}
}

You might also like