Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int N, a, i, j;
- int count[10] = {0};
- int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- scanf("%d", &N);
- for(i = 0; i < N; i++) {
- scanf("%d", &a);
- count[a-1]++;
- }
- for(i = 0; i < 9; i++)
- for(j = i+1; j < 10; j++)
- if(count[i] > count[j]) {
- int c;
- c = arr[i];
- arr[i] = arr[j];
- arr[j] = c;
- c = count[i];
- count[i] = count[j];
- count[j] = c;
- }
- for(i = 0; i < 10; i++)
- if(count[i] != 0)
- printf("%d %d\n", arr[i], count[i]);
- return 0;
- }
Add Comment
Please, Sign In to add comment