假设一个顺序表中所有元素为整数,设计一个算法,使其中小于零的元素移动到所有大于等于零的前面

假设一个顺序表中所有元素为整数,设计一个算法,使其中小于零的元素移动到所有大于等于零的前面
大家帮看看哪里出错了,第一次写,谢谢各位了


#define MaxSize 100000
#include<stdio.h>
#include<stdlib.h>

typedef int ElemType;
typedef struct{
    ElemType data[MaxSize];
    int length;
}List;

void InitList(List &l){
    l.length=0;
}
int InsElem(List &l,ElemType x,int i){
    int j;
    if(i<1||i>l.length+1)
        return 0;
    for(j=l.length;j>i;j--)
        l.data[j]=l.data[j-1];
    l.data[i-1]=x;
    l.length++;
    return 1;
}
void DispList(List l){
    int i;
    for(i=0;i<l.length;i++)
        printf("%d",l.data[i]);
    printf("\n");
}
void move(List &l){
    int i=0,j=l.length-1;
    while (l.data[i]>=0,i++,l.data[j]<0,j--);
    if (i<j)
        swap(l.data[i],l.data[j]);
    
}

int main(){
    int i;
    ElemType e;
    List l;
    InitList(l);
    InsElem(l,-1,1);
    InsElem(l,9,2);
    InsElem(l,-2,3);
    InsElem(l,0,4);
    InsElem(l,5,5);
    InsElem(l,-3,6); 
    printf("线性表:");DispList(l);
    move(l);
    printf("线性表:");DispList(l);
}

img

#define MaxSize 100000
#include<stdio.h>
#include<stdlib.h>
 
typedef int ElemType;
typedef struct{
    ElemType data[MaxSize];
    int length;
}List;
 
void InitList(List &l){
    l.length=0;
}
void swap(int *a,int *b) 
{
    int t=*a;*a=*b;*b=t;
}
int InsElem(List &l,ElemType x,int i){
    int j;
    if(i<1||i>l.length+1)
        return 0;
    for(j=l.length;j>i;j--)
        l.data[j]=l.data[j-1];
    l.data[i-1]=x;
    l.length++;
    return 1;
}
void DispList(List l){
    int i;
    for(i=0;i<l.length;i++)
        printf("%d ",l.data[i]);
    printf("\n");
}
void move(List &l){
    int i=0,j=l.length-1;
    /*while (l.data[i]>=0,i++,l.data[j]<0,j--)
    if (i<l.length)
    {
    swap(&l.data[i],&l.data[j]);
    } */
    for(i=0;i<l.length-1;i++)
    for(j=0;j<l.length-1-i;j++)
    if(l.data[j]>l.data[j+1]) swap(&l.data[j],&l.data[j+1]);
}
 
int main(){
    int i;
    ElemType e;
    List l;
    InitList(l);
    InsElem(l,-1,1);
    InsElem(l,9,2);
    InsElem(l,-2,3);
    InsElem(l,0,4);
    InsElem(l,5,5);
    InsElem(l,-3,6); 
    printf("线性表:");DispList(l);
    move(l);
    printf("线性表:");DispList(l);
}