1055解

#include<iostream>

using namespace std;

int num[110];

int n;

void work1(int x)

{

   cout<<num[x]<<endl;

}

void work2(int x,int y)

{

   for(int i=n;i>=x;i--)

          num[i+1]=num[i];

   num[x+1]=y;

   n++;

}

void work3(int x)

{

       for(int i=x;i<n;i++)num[i]=num[i+1];n--;

}

void work4(int x)

{

       for(int i=1;i<=n;i++)

       if(num[i]==x){cout<<i<<endl;return;}

       cout<<-1<<endl;

}

int main()

{

       int x,k,y,z;

       cin>>n;

       for(int i=1;i<=n;i++)cin>>num[i];

       cin>>k;

       for(int i=1;i<=k;i++)

              {

                     cin>>x;

              if(x==1){cin>>y;work1(y);}

              if(x==2){cin>>y>>z;work2(y,z);}

              if(x==3){cin>>y;work3(y);}

              if(x==4){cin>>y;work4(y);}

       }    

              return 0;

}

原文地址:https://www.cnblogs.com/lclde/p/7270040.html