u011652553 于 2013.09.30 08:20 提问

#include
using namespace std;
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
#define OVERFLOW -1
typedef struct
{
int *elem;
int length;
int listsize;
}SqList;
int InitList_Sp(SqList &l)
{
l.elem=new int[100];
if(!l.elem)exit(OVERFLOW);
l.listsize=LIST_INIT_SIZE;
return 0;
}
int insert(SqList &l,int i,int &e)
{

if(il.length+1)return -1;
if(l.length>=l.listsize)
{
int *newbase;
newbase=new int[110];
if(!newbase)
exit(OVERFLOW);
l.elem=newbase;
}
int *p;
int *q=&(l.elem[i-1]);
for(p=&(l.elem[l.length-1]);p>=q;--p)
*(p+1)=*p;
*q=e;
++l.length;
cout<<"the e"<<l.elem[i-1];
return e;
}
int chuangjian(SqList &l)
{

int i;

InitList_Sp(l);
cout<<"please input the number of the data "<<endl;

cin>>i;
cout<<"now you can input them"< for(int j=0;j {
cin>>l.elem[j];
}
return 0;
}
int main()
{
SqList l;
chuangjian(l);
int e;
cout<<"please input the number you want to insert"<<endl;

cin>>e;

int j;
cout<<"please input the location you want to put"<<endl;

cin>>j;
insert(l,j,e);
return 0;
}