/*
AUTORE: Vichingo455
The program deletes peer numbers from a vector using memmove
*/
#include <iostream>
#include <array>
#include <vector>
#include <cstdlib>
#include <cstring>
using namespace std;
void printVector(const vector<int> & vett) {
	for (int i = 0; i < vett.size(); i++)
		cout << vett.at(i) << " ";
	cout << endl;
}
void deletePeers(vector<int>& vec) {
    int* data = vec.data();
    size_t size = vec.size();
    size_t newSize = 0;
    for (size_t i = 0; i < size; ++i) {
        if (data[i] % 2 != 0) {
            if (newSize != i) {
                std::memmove(&data[newSize], &data[i], sizeof(int));
            }
            ++newSize;
        }
    }
    vec.resize(newSize);
}
int main() {
	vector<int> vett;
	int vectorSize;
	cout << "Insert the size of the vector: ";
	cin >> vectorSize;
	cout << endl;
	for (int i = 0,value; i < vectorSize; i++) {
		cout << "Insert a value: ";
		cin >> value;
		vett.push_back(value);
		cout << endl;
	}
	printVector(vett);
	deletePeers(vett);
	printVector(vett);
    return 0;
}
