Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main(void)
- {
- int n;
- cin >> n;
- int k;
- cin >> k;
- int *a = new int [n];
- for (int i=0; i<n; i++)
- cin >> a[i];
- int max_el=a[0];
- for (int i=0; i<n; i++)
- max_el=max(max_el,a[i]);
- int *b=new int [2*n];
- int pos=0;
- for (int i=0; i<n; i++)
- {
- b[pos]=a[i];
- pos ++;
- if (a[i]==max_el)
- {
- b[pos]=k;
- pos ++;
- }
- }
- for (int i=0; i<pod; i++)
- cout << b[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment