Hello, so I recently started reading on arrays and I have an assignment to make a program that removes the necessary elements from an array of integers so that the array consists only of increasing integers, for example, transform {2,3,5,1,6,2,3} to {2,3,5,6}. Now, I do not know of any possible ways to remove elements from an array, so I tried overwriting the bad values and shitfing the array to the left, but I still need to remove the elements from the right-end of the array. My code is not really working properly but thats just a blueprint, anyone has got any idea how to do this right or has a different approach to this? Thanks in advance!
#include <iostream>
using namespace std;
int main ()
{
int ok;
do
{
int size;
cout << "Input array size" << endl;
cin >> size;
int arr[size];
cout << "Input " << size << " array elements" << endl;
for (int i=0; i<size; i++)
{
cin >> arr[i];
}
for (int i=1; i<size; i++)
{
if (arr[i-1]>arr[i])
{
for (int j=i; j<(size-1); j++)
{
arr[j] = arr[j+1];
}
}
}
for (int i=0; i<size; i++)
{
cout << arr[i];
}
cout << endl;
cout << "Continue (1) or end (0)" << endl;
cin >> ok;
} while (ok==1);
return 0;
}