没调过,但大部分帮你改过来了,应该没大错误了,你稍微看看应该能搞定了!话说,你写的代码真的很难读,得注意。还有尽量不要传递引用,改用指针。and申请了内存用完要释放!!!
#include
#include
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef int ElemType
#define OK 0
#define OVERFLOW 0
typedef struct
{
ElemType * elem;
int listsize;
}SqlList;
int InitList(SqlList &L)
{
L.listsize=LIST_INIT_SIZE;
for(int=0;i
{
L.elem[i]=i;
}
return OK;
}
int PaiXu(SqlList &L)
{
int i,k,temp;
for(i=0;i
{
if(L.elem[i]%2==0)
{ for(k=L.listsize-1;k>L.listsize/2-1;k--)
{
if(L.elem[k]%2==1)
{
temp=L.elem[i];
L.elem[i]=L.elem[k];
L.elem[k]=temp;
}
}
}
}
return Ok;
}
void DisList(SqlList &L)
{
int i=0;
while(L.elem[i])
{
printf("%n",L.elem[i]);
i++;
}
}
void main()
{
SqlList L;
L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L.elem)
exit(OVERFLOW);
InitList(L);
PaiXu(L);
DisList(L);
if(L.elem!=NULL)
free(L.elem);
}
温馨提示:答案为网友推荐,仅供参考