简体   繁体   中英

C:[error]linked list quicksort

I was writing the linked list quick sort.

void quick(NODE low,NODE High){
NODE stan=low, serch=NULL;
int pivot,temp

if(low==end || low -> Next =high || low == high){return;}

serch=stan -> Next;
pivot= stan -> data;

while(serch != high){
    if(serch -> data <= pivot){
        if(serch != pivot){
            temp= serch -> data;
            serch -> data =stan -> next ->data; 
            stan -> next ->data=temp;
        }
        stan = stan -> Next;
    }
}   
quick(low, stan);

quick(stan -> next,end);
}

but

[Error] invalid initializer

[Error] expected '=', ',', ';', 'asm' or ' attribute ' before 'if'

[Error] invalid type argument of '->' (have 'NODE')

[Error] invalid type argument of '->' (have 'NODE')

[Error] 'high' undeclared (first use in this function)

[Note] each undeclared identifier is reported only once for each function it appears in [Error] invalid type argument of '->' (have 'NODE')

[Error] invalid operands to binary != (have 'NODE' and 'int')

[Error] 'temp' undeclared (first use in this function)

[Error] invalid type argument of '->' (have 'NODE')

[Error] invalid type argument of '->' (have 'NODE')

[Error] invalid type argument of '->' (have 'NODE')

[Error] invalid type argument of '->' (have 'NODE')

[Error] invalid type argument of '->' (have 'NODE')

[Error] invalid type argument of '->' (have 'NODE')

[Error] incompatible type for argument 2 of 'quick'

[Note] expected 'NODE' but argument is of type 'struct NODE *'

error why?

1.you miss ; after int pivot,temp
2. low -> Next =high should be low -> Next ==high you should use == ,
3.your parameter is High void quick(NODE low,NODE High) , but you use high ,you should change
4.i guess NODE 's type is struct ,you should use NODE.parameter ,and if you want to use -> ,you should use struct pointer ,so you need to define NODE *

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM