求助。。。顺序表插入的问题
#include "stdafx.h"#include "iostream.h"
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef struct{
int *elem;
int length;
int listsize;
int incrementsize;
}SqList;
typedef struct LNode {
int data;
struct LNode *next;
}LNode,*LinkList;
void huhu(SqList &L,int maxsize=LIST_INIT_SIZE,int incresize=LISTINCREMENT)
{L.elem=new int[maxsize];
L.length=0;
L.listsize=maxsize;
L.incrementsize=incresize;
}
void huhu1(SqList &va,int x)
{int i;
va.length++;
for(i=va.length-2;va.elem[i]>x&&i>=0;i--)
va.elem[i+1]=va.elem[i];
va.elem[i+1]=x;
}
void huhu2(SqList &va)
{int i;
for(i=0;i<va.length;i++)
cout<<va.elem[i]<<" ";
}
int main(int argc, char* argv[])
{SqList L;
int i;
huhu(L,LIST_INIT_SIZE,LISTINCREMENT);
L.length=6;
for(i=0;i<L.length-1;i++)
cin>>L.elem[i]>>" ";
huhu1(L,3);
huhu2(L);
return 0;
}
定义一个递增的顺序表然后插入一个数使他仍然递增。。。。。请高手看下错在哪里了