There are N license. Each license has four-digit integer, each integer between 1 to 9. For example, if N=7, the input may look like
7
1324
5566
3578
4123
5656
4312
9847
We want to get the licenses that use the same digits and the digits should be sorted from small to large. For example, 1324, 4123, and 4312 are the combination of the same digits (1, 2, 3, and 4). We want to get 1234. Similarly, 5566 and 5656 are the combination of the same digits (5, 5, 6, and 6). We want to get 5566.
For output, we list the modified licenses in an increasing order line by line, so the output will look
1234
5566
<Hint>
You may consider the following algorithm:
0. Create a character array (char str[5];) for storing the input integers and create an array which is initialed to zero (int HIT[10000];) to record the occurrences of input integers.
1. Read the number of input integers and store it in variable N (scanf("%d", &N);).
2. For each of the next N integers, do
2.1 Read the four-digit integer and store it as a four-character string in str.
2.2 Use the bubble sort algorithm to rearrange the four characters.
2.3 Convert the rearranged string to an integer m and increase the value of the corresponding element of the HIT array by 1 (HIT[m]++;).
3. Check each element of the HIT array; if its value is larger than 2, print the corresponding integer.
The bubble sort algorithm:
/* Using bubble sort to rearrange an array A[n] */
for (i = n; i > 0; i--) {
for (j = 1; j < i; j++) {
if (A[j-1] > A[j]) {
/* swap A[j-1] A[j] */
}
}
}
The first line contains a number N (1<=N<=100).
The next N lines provide the N four-digit integers.
Each line shows a modified unique integer as explained in the problem description.
Remember to print a newline at the end of each line.