#pragma once#include #include using namespace std;typedef int DataType;class SList{public: SList() :_p(NULL), _size(0), _capcity(0) { }; SList(SList & s) { if (s._p == NULL) return; DataType *tmp = new DataType[s._size]; _p = tmp; memcpy(_p, s._p, s._size*sizeof(DataType)); _size = s._size; _capcity = _size; } SList& operator=(const SList &s) { if (&s != this) { DataType *tmp = new DataType[s._size]; memcpy(tmp, s._p,s._size); delete[]_p; _p = tmp; _size = s._size; _capcity = s._capcity; } return *this; } ~SList() { if (_p) { delete[]_p; } } void UpdateCup() { _capcity = 2 * _capcity + 3; _p = (DataType *)realloc(_p, (sizeof(DataType)*_capcity)); } void PushBack(DataType x) { if (_size >= _capcity) { UpdateCup(); } _p[_size] = x; ++_size; } void PopBack() { if (_size <= 0) return; --_size; } void PrintSlist() { for (int i = 0; i < _size; ++i) { cout << _p[i] << "->"; } cout << "NULL"< <0 && pos>_size) return; if (_size >= _capcity) { UpdateCup(); } ++_size; for (int i = _size; i > pos; i--) { _p[i] = _p[i - 1]; } _p[pos] = x; }private: DataType *_p; size_t _size; size_t _capcity;};