class Stack {
public:
	Stack() = default;
	Stack(const Stack& other) :size(other.size) {
		this->data = new int[other.size];
		for (size_t i = 0; i < other.size; i++) {
			this->data[i] = other.data[i];
		}
	}

	Stack& operator=(const Stack& x) {
		if (&x != this) {
			delete[] data;

			this->data = new int[x.size];
			for (size_t i = 0; i < x.size; i++) {
				this->data[i] = x.data[i];
			}
			size = x.size;
		}
		return *this;
	}

	Stack(Stack&& other) noexcept : size(other.size), data(other.data) {
		other.data = nullptr;
		other.size = 0;
	}

	Stack& operator=(Stack&& x) noexcept {
		if (&x != this) {
			delete[] data;
			size = x.size;
			data = x.data;

			x.data = nullptr;
			x.size = 0;

		}
		return *this;
	}
	void setSize(size_t size) {
		this->size = size;
	}
	void push(int element) {
		int* copy_arr = new int[size + 1];
		for (size_t i = 0; i < size; i++) {
			copy_arr[i + 1] = data[i];
		}
		copy_arr[0] = element;
		size++;
		delete[] data;
		data = copy_arr;
	}
	void pop() {
		int* copy_arr = new int[size - 1];
		for (size_t i = 0; i < size - 1; i++) {
			copy_arr[i] = data[i + 1];
		}
		size--;
		delete[] data;
		data = copy_arr;
	}
	void swap(Stack& other) {
		if (this == &other)
			return;
		size_t tmpSz = other.size;
		other.size = size;
		size = tmpSz;
		int* tmpData = other.data;
		other.data = data;
		data = tmpData;
	}
	int top() {
		return data[size-1];
	}
	bool isEmpty() {
		return size == 0;
	}
	int get(size_t index) {
		return data[index];
	}
	int getSize() {
		return size;
	}


	~Stack() {
		
	}

private:
	size_t size;
	int* data = new int[size];
};

void print(Stack& stack) {
	for (size_t i = 0; i < stack.getSize(); i++) {
		std::cout.width(7);
		std::cout << stack.get(i);
	}
	std::cout << std::endl;
}

int main(){
	Stack stack;
	stack.push(1);
	stack.push(2);
	stack.push(3);

	print(stack);
	stack.pop();
	stack.pop();
	print(stack);
	std::cout.width(7);
	std::cout << stack.top();
}