Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <climits>
- using namespace std;
- int main()
- {
- bool flag = false;
- int array[100];
- int length1, i, maxSequence = INT_MIN, sequence = 1, mostUsedNum = 0;
- cin >> length1;
- for (i = 0; i < length1; i++)
- {
- cin >> array[i];
- }
- for (i = 0; i < length1; i++)
- {
- if (array[i] != array[i + 1])
- {
- sequence = 1;
- }
- else
- {
- sequence++;
- flag = true;
- }
- if (sequence > maxSequence)
- {
- maxSequence = sequence;
- mostUsedNum = array[i];
- }
- }
- if (flag == false)
- {
- cout << array[length1 - 1];
- }
- else
- {
- while (maxSequence > 0)
- {
- cout << mostUsedNum << " ";
- maxSequence--;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement