Replace all repeated numbers with the value 0 and display the number of unique numbers of the vector

Asked

Viewed 15 times

-2

import java.util.Scanner;

public class Vetor {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        
        System.out.println("DIGITE O TAMANHO DO VETOR: ");
        int N = input.nextInt();
        int[] vetor = new int[N];
        vetor[1] = 10; 
        vetor[2] = 20;
        vetor[3] = 30;
        vetor[4] = 40;
        vetor[5] = 50;
        
        for(int i = 1; i < vetor.length; i++) {
            vetor[i] = i;
        }

        for(int i = 1; i < vetor.length; i++) {
            System.out.println(vetor[i]);
        }   
    }
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.