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