Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   linear register (http://www.go4expert.com/forums/linear-register-t4588/)

 logistic 7Jun2007 03:01

linear register

Hi, i'm sorry for bothering you, i wanted to arrange numbers (ascending), i tought everything is ok, but... where's the problem? Thanks...

Code:

```void sort(){ elementi *temp = first, *next, *t1, *t2; for(next = temp->next; next !=NULL; next = temp->next){ next=temp->next; if(temp->value > next->value) { if(next!=last){ t1=temp; t2=next; t1->next=next->next; temp=t2; next=t1;} else { t1=temp; t1->next=NULL; t1=last; temp=temp->next; temp->next=t1; }} else {  temp = temp->next; }} };```

 DaWei 7Jun2007 07:53

Re: linear register

You're supposed to tell us what you expect to happen and how that's failing to happen. You are also supposed to tell us what things like "elementi" are. You're looking at your code and can't figure it out, but you want us to do it with guesses. Nuh uh.

 logistic 7Jun2007 12:00

Re: linear register

My CODE looks like that, but, for example i enter values 1, 5, 4, 10 -> i suppose to see out -> 1, 4, 5 10, but i see just -> 1, 5, 10 :confused:
Code:

```class klase {       struct elementi {                       int value;            //value of node                       elementi *next;                       };       elementi *current, *last, *first;       public :             klase(){last = current = first = NULL;}                                    ~klase() { izdzest(); };           void sort(){     elementi *temp = first, *next, *t1, *t2;     for(next = temp->next; next !=NULL; next = temp->next){               next=temp->next;           if(temp->value > next->value) {           if(next!=last){             t1=temp;             t2=next;             t1->next=next->next;             temp=t2;             next=t1;}         else { t1=temp;             t1->next=NULL;             t1=last;             temp=temp->next;             temp->next=t1; }}         else {            temp = temp->next; }} };```

 All times are GMT +5.5. The time now is 11:00.