Created
February 6, 2025 18:10
-
-
Save jxcto/68de791f6af12c91476acb58e582ea99 to your computer and use it in GitHub Desktop.
Exercicio 6 - Vetores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package application; | |
import java.util.Locale; | |
import java.util.Scanner; | |
public class Program { | |
public static void main(String[] args) { | |
Locale.setDefault(Locale.US); | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Quantos valores vai ter cada vetor? "); | |
int n = sc.nextInt(); | |
int vectA[] = new int[n]; | |
int vectB[] = new int[n]; | |
int vectC[] = new int[n]; | |
System.out.println("Digite os valores do vetor A: "); | |
for (int i = 0; i < n; i++) { | |
vectA[i] = sc.nextInt(); | |
} | |
System.out.println("Digite os valores do vetor B: "); | |
for (int i = 0; i < n; i++) { | |
vectB[i] = sc.nextInt(); | |
} | |
System.out.println("VETOR RESULTANTE:: "); | |
for (int i = 0; i < n; i++) { | |
System.out.println(vectC[i] = vectA[i] + vectB[i]); | |
} | |
sc.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment