标签:
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int n=sc.nextInt(); int b[]=new int[n]; for(int i=0;i<n;i++){ b[i]=sc.nextInt(); } Arrays.sort(b); for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(b[i]==b[j] && b[i]!=-1) b[j]=-1; } } int sum=0; for(int i=0;i<n;i++){ if(b[i]!=-1){ sum++; } } System.out.println(sum); for(int i=0;i<n;i++){ if(b[i]!=-1) System.out.print(b[i]+" "); } } } }
标签:
原文地址:http://www.cnblogs.com/watchfree/p/5345792.html