-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path49.java
More file actions
39 lines (31 loc) · 1.17 KB
/
49.java
File metadata and controls
39 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*******************************************************************************
* 49) Leia 2 vetores de inteiros V1 e V2 de N componentes cada (no máximo 50).
* Determine e imprima quantas vezes que V1 e V2 possuem valores idênticos nas
* mesmas posições.
*******************************************************************************/
import java.util.Scanner;
public class Exercicio {
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
int NumeroComponentes;
System.out.print("Digite o número de posições: ");
NumeroComponentes = entrada.nextInt();
System.out.println();
int[]v1= new int[NumeroComponentes];
int[]v2= new int[NumeroComponentes];
for(int x=0;x<NumeroComponentes;x++){
System.out.print("Digite um valor para a posição "+(x+1)+" do vetor 1: ");
v1[x]= entrada.nextInt();
}
for(int x=0;x<NumeroComponentes;x++){
System.out.print("Digite um valor para a posição "+(x+1)+" do vetor 2: ");
v2[x]= entrada.nextInt();
}
System.out.println();
for(int x=0;x<NumeroComponentes;x++){
if(v1[x]==v2[x]){
System.out.println("Valores das Posições "+(x+1)+" dos vetores é igual.");
}
}
}
}