Integer deduplication

Given a sequence of n integers, a deduplication operation is required on this sequence. The so-called deduplication means that for each repeated number in the sequence, only the first occurrence of the number is retained, and the rest are deleted.
enter

The input contains two lines:

The first line contains a positive integer n (1 <= n <= 20000), which represents the number of digits in the second line sequence;

The second line contains n integers separated by a space. Each integer is greater than or equal to 10 and less than or equal to 100.
Output The
output is only one line, and the non-repeated numbers are output in the order of input, and the integers are separated by a space.
Sample input
5
10 12 93 12 75

Sample output
10 12 93 75

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,i,j,k;
        n=scan.nextInt();
        int[] a=new int[20001];
        for(i=0;i<n;i++){
            a[i]=scan.nextInt();
        }
        for(i=0;i<n-1;i++){
            for(j=i+1;j<n;j++)
                if(a[i]==a[j]){
                    for(k=j;k<n-1;k++)
                        a[k]=a[k+1];
                    n--;
                    j--;
                }
        }
        for(i=0;i<n;i++)
            System.out.print(a[i]+" ");

    }
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326643566&siteId=291194637