Title Description
Obviously want to ask some students in school to do a questionnaire survey, in order to the objectivity of the experiment, he first used a computer to generate N 1 to 1000 random integer (n≤100), for the repeated numbers, only one, the rest of the same number is removed, the different numbers correspond to different student's number. Then the numbers from small to large sorting, in line with the order to find students to do the investigation. Please help clearly to complete the "go to Heavy" and "sort" work.
Input Format
The input has 2 rows, and the 1th behavior is 1 positive integers, indicating the number of random numbers generated:
N
The 2nd line has n spaces separated by a positive integer, which is the resulting random number.
output Format
The output is also 2 lines, and the 1th behavior is 1 positive integer m, which represents the number of different random numbers. The 2nd behavior is a positive integer separated by a space, which is a different random number from small to large sequence.
Sample input
10
20 40 32 67 40 20 89 300 400 15
Sample output
8
15 20 32 40 67 89 300 400
1#include <stdio.h>2#include <algorithm>3 using namespacestd;4 intMain ()5 {6 inta[ +],n,i;7 while(SCANF ("%d", &n) = =1)8 {9 for(i=0; i<n;i++)Tenscanf"%d",&a[i]); OneSort (a,a+n);/* argument an array's first address and end address */
A intCount=unique (A,a+n)-a;/* two parameters for the first address and the end address of the array to be processed, unique deduplication, and delete adjacent duplicate elements, keep one, the rest of the array at the end, unique returns the address of the first repeating element after processing * / -printf"%d\n", count); - for(i=0; i<count;i++) theprintf"%d", A[i]); - } -}
The random number of the Ming