#include <iostream>
using namespace std;
class arrList{
private:
int* aList;
int curLen;//顺序表的当前长度
public:
int maxSize;//顺序表的实例的最大长度
void set(const int size){
maxSize=size;
aList=new int[maxSize];
curLen=0;
}
bool insert(const int value);
void print();
bool delete_manny(int n,int k);
};
bool arrList::delete_manny(int n,int k){
for (int i=0;i<k;i++)
{
for (int j=n-1;j<curLen-1;j++)
{
aList[j]=aList[j+1];
}
curLen--;
}
return true;
}
void arrList::print(){
cout<<endl;
for (int i=0;i<curLen;i++)
{
cout<<aList[i]<<" ";
}
cout<<endl;
}
bool arrList::insert(const int value){
if (curLen>maxSize)
{
cout<<"The arrList is overflow\n";
return false;
}
aList[curLen]=value;
curLen++;
return true;
}
int main(){
arrList a;
a.set(100);
a.insert(1);
a.insert(2);
a.insert(3);
a.insert(4);
a.insert(5);
a.insert(6);
a.insert(7);
a.insert(9);
a.print();
a.delete_manny(3,5);
a.print();
return 0;
}
using namespace std;
class arrList{
private:
int* aList;
int curLen;//顺序表的当前长度
public:
int maxSize;//顺序表的实例的最大长度
void set(const int size){
maxSize=size;
aList=new int[maxSize];
curLen=0;
}
bool insert(const int value);
void print();
bool delete_manny(int n,int k);
};
bool arrList::delete_manny(int n,int k){
for (int i=0;i<k;i++)
{
for (int j=n-1;j<curLen-1;j++)
{
aList[j]=aList[j+1];
}
curLen--;
}
return true;
}
void arrList::print(){
cout<<endl;
for (int i=0;i<curLen;i++)
{
cout<<aList[i]<<" ";
}
cout<<endl;
}
bool arrList::insert(const int value){
if (curLen>maxSize)
{
cout<<"The arrList is overflow\n";
return false;
}
aList[curLen]=value;
curLen++;
return true;
}
int main(){
arrList a;
a.set(100);
a.insert(1);
a.insert(2);
a.insert(3);
a.insert(4);
a.insert(5);
a.insert(6);
a.insert(7);
a.insert(9);
a.print();
a.delete_manny(3,5);
a.print();
return 0;
}