JoseLargo

Untitled

Dec 6th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. package ejercicio3;
  2.  
  3. import java.util.*;
  4. public class Ejercicio3 {
  5.  
  6.    
  7.     public static void main(String[] args) {
  8.         Scanner sc= new Scanner (System.in);
  9.         int [] v1;
  10.         int [] v2;
  11.         int [] vresul;
  12.         int tam;
  13.        
  14.         System.out.println("Introduce tamaƱo de tus vectores: ");
  15.         tam=sc.nextInt();
  16.         v1=new int[tam];
  17.         v2=new int[tam];
  18.         vresul= new int[tam];
  19.        
  20.         for (int i = 0; i < tam; i++) {
  21.             System.out.println("Introduce dato numero "+i+" para primer array");
  22.             v1[i]=sc.nextInt();
  23.         }
  24.        
  25.         for (int i = 0; i < tam; i++) {
  26.             System.out.println("Introduce dato numero "+i+" para segundo array");
  27.             v2[i]=sc.nextInt();
  28.         }
  29.         System.out.print("Su resultado es: ");
  30.         for (int j = 0; j < tam; j++) {
  31.             vresul[j]=v1[j]*v2[j];
  32.             System.out.print(vresul[j]+" ");
  33.         }
  34.     }
  35. }
Add Comment
Please, Sign In to add comment