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