Advertisement
cesarnascimento

vetores imprimir A e B

May 26th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package loiane;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class blz {
  6.  
  7.     public static void main(String[] args) {
  8.        
  9.         int[] vA = new int[5];
  10.         int[] vB = new int[vA.length];
  11.        
  12.         Scanner sc = new Scanner(System.in);
  13.        
  14.         for(int i = 0;i<vA.length;i++){
  15.             System.out.println("Digite o valor da posição: "+(i+1));
  16.             vA[i] = sc.nextInt();
  17.             vB[i] = vA[i]; // B recebe o mesmo valor de A
  18.            
  19.         }
  20.        
  21.         // imprimir valores A
  22.         System.out.println("Vetor A = ");
  23.         for(int i =0; i<vA.length;i++){
  24.             System.out.printf(vA[i] +" ");
  25.         }
  26.  
  27.         System.out.println("Vetor B = ");
  28.         for(int i=0; i<vA.length;i++){
  29.             System.out.printf(vB[i] +" ");
  30.         }
  31.  
  32.     }
  33.     /* CΓ©sar N. */
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement