#include<bits/stdc++.h>
using namespace std;
template<class T>
class llist{
private:
T *date;
int length;
public:
llist(){};
void get_length(){
cout<<length<<endl;
}
llist(T a[],int n)
{
this->date=new T[n];
for(int i=0;i<n;i++)
date[i]=a[i];
length=n;
}
void sett(T a[],int n)
{
this->date=new T[n];
for(int i=0;i<n;i++)
date[i]=a[i];
length=n;
}
void Delete(int i){
if(i<1||i>length+1)throw"位置";
for(int j=i-1;j<length;j++){date[j]=date[j+1];}length--;
}
friend ostream & operator <<(ostream & out,const llist &a)
{
for(int i=0;i<a.length;i++)
{
if(i==0)out<<a.date[i];
else out<<" "<<a.date[i];
}
return out;
}
void Insert(T x)//插入
{
for(int j=length;j>=2;j--)date[j]=date[j-1];
date[2-1]=x;
length++;
}
void Locate(T x){
for(int i=0;i<length;i++)
{if(date[i]==x)cout<<i+1;}
}
};
int main(){
int a[10000];
int n;
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
llist<int>mm;
mm.sett(a,n);
cout<<mm<<endl;
mm.Delete(1);
cout<<mm<<endl;
mm.get_length();
mm.Insert(100);
cout<<mm<<endl;
mm.Locate(100);
return 0;
}
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/317344440566177.png?x-oss-process=image/auto-orient,1/resize,w_320,m_lfit)