Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int k;
- cin >> k;
- int a[100];
- for (int i = 0; i < k; i++)
- cin >> a[i];
- for (int i = 0; i < k - 1; i++)
- for (int j = 0; j < k - i - 1; j++)
- if (a[j] > a[j + 1]) {
- int temp = a[j];
- a[j] = a[j + 1];
- a[j + 1] = temp;
- }
- int temp = 1;
- int iMax = 1;
- int max = 1;
- for (int i = 1; i < k; i++)
- if (a[i] = a[i - 1])
- temp++;
- else {
- if (temp > max) {
- max = temp;
- iMax = i;
- }
- temp = 1;
- }
- cout << a[iMax];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement