#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
class CIntArray {
private:
int *m_Array;
int m_Length;
public:
CIntArray();
CIntArray(const CIntArray& temp);
CIntArray(int len);
~CIntArray();
void InputArray();
void OutputArray();
CIntArray Remove();
CIntArray Remove(int k);
CIntArray Remove(int n, int k);
CIntArray Replace(int oldVal, int newVal);
CIntArray AddHead(int val);
CIntArray AddTail(int val);
CIntArray Insert(int val, int k);
int Max();
int Min();
CIntArray Ascending();
CIntArray Descending();
bool IsSymmetry();
CIntArray MoveForward();
CIntArray MoveForward(int n);
CIntArray MoveBehind();
CIntArray MoveBehind(int n);
CIntArray Invert();
int Appearance(int val);
};
CIntArray::CIntArray() : m_Array(nullptr), m_Length(0) {}
CIntArray::CIntArray(int len) : m_Length(len) {
if(len < 0) {
CIntArray();
return;
}
m_Array = new int[len];
for (int i = 0; i < m_Length; ++i)
m_Array[i] = 0;
}
CIntArray::CIntArray(const CIntArray& temp) : m_Length(temp.m_Length) {
if(m_Length <= 0) {
CIntArray();
return;
}
m_Array = new int[m_Length];
for (int i = 0; i < m_Length; ++i)
m_Array[i] = temp.m_Array[i];
}
CIntArray::~CIntArray() {
delete[] m_Array;
m_Array = nullptr;
m_Length = 0;
}
void CIntArray::InputArray() {
cin >> m_Length;
if (m_Length < 0) {
m_Length = 0;
delete[] m_Array;
m_Array = nullptr;
return;
}
delete[] m_Array;
m_Array = new int[m_Length];
for (int i = 0; i < m_Length; ++i) {
cin >> m_Array[i];
}
}
void CIntArray::OutputArray() {
if (m_Length == 0) {
cout << "Mang rong." << '\n';
return;
}
for (int i = 0; i < m_Length; ++i) {
cout << m_Array[i] << " ";
}
cout << '\n';
}
CIntArray CIntArray::Remove() {
if (m_Length == 0) {
return *this;
}
int cnt = 0;
for(int i = 0; i < m_Length; ++i) {
bool isUnique = true;
for(int j = 0; j < i; ++j)
if(m_Array[i] == m_Array[j]) {
isUnique = false;
break;
}
cnt += isUnique;
}
CIntArray result(cnt);
cnt = 0;
for(int i = 0; i < m_Length; ++i) {
bool isUnique = true;
for(int j = 0; j < i; ++j)
if(m_Array[i] == m_Array[j]) {
isUnique = false;
break;
}
if(isUnique) {
result.m_Array[cnt++] = m_Array[i];
}
}
return result;
}
CIntArray CIntArray::Remove(int k) {
if(k < 0 || k >= m_Length || m_Length == 0)
return *this;
CIntArray result(m_Length - 1);
for (int i = 0, j = 0; i < m_Length; ++i) {
if (i != k) {
result.m_Array[j++] = m_Array[i];
}
}
return result;
}
CIntArray CIntArray::Remove(int n, int k) {
if(k < 0 || k >= m_Length || m_Length == 0)
return *this;
if(k + n > m_Length) {
n = m_Length - k;
}
CIntArray result(m_Length - n);
for (int i = 0, j = 0; i < m_Length; ++i) {
if (i < k || i >= k + n) {
result.m_Array[j++] = m_Array[i];
}
}
return result;
}
CIntArray CIntArray::Replace(int oldVal, int newVal) {
CIntArray result(*this);
for (int i = 0; i < result.m_Length; ++i) {
if (result.m_Array[i] == oldVal) {
result.m_Array[i] = newVal;
}
}
return result;
}
CIntArray CIntArray::AddHead(int val) {
CIntArray result(m_Length + 1);
result.m_Array[0] = val;
for (int i = 0; i < m_Length; ++i) {
result.m_Array[i + 1] = m_Array[i];
}
return result;
}
CIntArray CIntArray::AddTail(int val) {
CIntArray result(m_Length + 1);
for (int i = 0; i < m_Length; ++i) {
result.m_Array[i] = m_Array[i];
}
result.m_Array[m_Length] = val;
return result;
}
CIntArray CIntArray::Insert(int val, int k) {
if (k < 0) {
return AddHead(val);
}
if (k >= m_Length) {
return AddTail(val);
}
CIntArray result(m_Length + 1);
for (int i = 0, j = 0; i <= m_Length; ++i) {
if (i == k) {
result.m_Array[i] = val;
} else {
result.m_Array[i] = m_Array[j++];
}
}
return result;
}
int CIntArray::Max() {
int res = m_Array[0];
for(int i = 1; i < m_Length; ++i)
res = max(res, m_Array[i]);
return res;
}
int CIntArray::Min() {
int res = m_Array[0];
for(int i = 1; i < m_Length; ++i)
res = min(res, m_Array[i]);
return res;
}
CIntArray CIntArray::Ascending() {
CIntArray result(*this);
sort(result.m_Array, result.m_Array + result.m_Length);
return result;
}
CIntArray CIntArray::Descending() {
CIntArray result(*this);
sort(result.m_Array, result.m_Array + result.m_Length, greater<int>());
return result;
}
bool CIntArray::IsSymmetry() {
for(int i = 0; i < m_Length / 2; ++i)
if(m_Array[i] != m_Array[m_Length - 1 - i])
return false;
return true;
}
CIntArray CIntArray::MoveForward() {
if(m_Length <= 0)
return *this;
CIntArray result(m_Length - 1);
for (int i = 0; i < result.m_Length; ++i) {
result.m_Array[i] = m_Array[i + 1];
}
if(result.m_Length == 0) {
m_Array = nullptr;
}
return result;
}
CIntArray CIntArray::MoveForward(int n) {
if(n >= m_Length) {
return CIntArray(0);
}
CIntArray result(m_Length - n);
for(int i = n, j = 0; i < m_Length; ++i) {
result.m_Array[j++] = m_Array[i];
}
return result;
}
CIntArray CIntArray::MoveBehind() {
CIntArray result(m_Length + 1);
for (int i = 0; i < m_Length; ++i) {
result.m_Array[i + 1] = m_Array[i];
}
return result;
}
CIntArray CIntArray::MoveBehind(int n) {
CIntArray result(m_Length + n);
for(int i = n; i < result.m_Length; ++i) {
result.m_Array[i] = m_Array[i - n];
}
return result;
}
CIntArray CIntArray::Invert() {
CIntArray result(*this);
reverse(result.m_Array, result.m_Array + result.m_Length);
return result;
}
int CIntArray::Appearance(int val) {
int cnt = 0;
for (int i = 0; i < m_Length; ++i) {
if (m_Array[i] == val) {
cnt++;
}
}
return cnt;
}
int32_t main() {
return 0;
}