Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int length, index = 0, count = 1, maxCount = 0;
- cin >> length;
- int* numbers = new int[length];
- for (int i = 0; i < length; i++) {
- cin >> numbers[i];
- }
- for (int i = 1; i <= length; i++) {
- if (numbers[i - 1] != numbers[i]) {
- if (count >= maxCount) {
- index = i - count;
- maxCount = count;
- }
- count = 1;
- }
- else {
- count++;
- }
- }
- for (int i = index; i < index + maxCount; i++) {
- cout << numbers[i] << ' ';
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement