Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int count[16];
- int names[16];
- for(int i = 0; i < n; ++i) {
- count[i] = 0;
- names[i] = i;
- }
- for(int i = 0; i < n; ++i) {
- names[i] = i;
- }
- int n;
- cin >> n;
- int x;
- for(int i = 0; i < n; ++i) {
- cin >> x;
- ++count[x - 1];
- }
- for(int i = 0; i < 15; ++i) {
- for(int j = i + 1; j < 16; ++j) {
- if(count[j] > count[i]) {
- swap(count[i], count[j]);
- swap(names[i], names[j]);
- }
- }
- }
- for(int i = 0; i < 16; ++i) {
- if(count > 0) {
- cout << names[i] << " " << count[i] << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement