Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Enter a number of arrays's elements: ";
- int n;
- cin >> n;
- cout << endl;
- int* mass = new int[n];
- for (int i = 0; i < n; i++)
- {
- cout << "mass[" << i << "] = ";
- cin >> mass[i];
- }
- int temp = 0;
- int zn;
- for (int i = 0; i < n; i++)
- {
- if (mass[i] < 0)
- {
- zn = mass[i];
- for (int j = i; j > temp; j--)
- {
- mass[j] = mass[j - 1];
- }
- mass[temp] = zn;
- temp++;
- }
- }
- cout << "Changed mass: " << endl;
- for (int i = 0; i < n; i++)
- cout << mass[i] << " ";
- delete[] mass;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement