Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- #include<stdio.h>
- #include <algorithm>
- using namespace std;
- int a[1000];
- const int INF = 1e9;
- int main()
- {
- int n;
- cin >> n;
- int k;
- cin >> k;//какой элемент вставлять
- int Max = -INF;
- for (int i = 0; i < n; ++i)
- {
- cin >> a[i];
- Max = max(Max, a[i]);
- }
- for (int i = 0; i < n; ++i)
- if (a[i] == Max)
- {
- for (int j = n; j > i; j--)
- a[j] = a[j - 1];
- a[i + 1] = k;
- i++;
- n++;
- }
- for (int i = 0; i < n; ++i)
- cout << a[i] << ' ';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement