GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-Jun-2007, 14:18
logistic logistic is offline
New Member
 
Join Date: Jun 2007
Posts: 1
logistic is on a distinguished road

Linear register


Hi, I'm sorry for bothering you, but I have a serious problem which I cannot solve. I have to arrange numbers (from smaller to bigger one)

CPP / C++ / C 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;
                           }}                
                         };
Last edited by admin : 07-Jun-2007 at 00:20. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 08-Jun-2007, 15:10
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,821
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Linear register


Quote:
Originally Posted by logistic
Hi, I'm sorry for bothering you
It's not a bother; I just don't know how to help.

If this is supposed to sort a list that has been built, I will note that, in general, you simply can't do it with one pass through the given list. Not the way that you appear to be trying, and not without some stuff you haven't shown.

If you have already implemented a sort routine with an array, try to write a description of the code in a generic pseudo-language. Then see if you can get through the list in the same ways using a linked list.

I think that for best chances of meaningful help you might consider posting the code that shows how you built the list and showing how you tested the sort routine. (Print the list before sorting and print the list after sorting.)

That way, we might be able to pinpoint some of your problems rather than just answering a lot of questions that you haven't asked.

Ask specific questions about whatever behavior you don't understand. Just saying, "I have a serious problem," doesn't give us much to work on.


Regards,

Dave
 
 

Recent GIDBlogUS Elections and the ?Voter?s Responsibility? by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Register Domain Name & Get 50MB Linux Hosting Free at www.igndomains.com ignhost Web Hosting Advertisements & Offers 0 16-Oct-2006 03:04
Code for receiving data from parallel port in VB.net harry.net .NET Forum 1 10-Mar-2006 16:41
Converting array to linear linked list ejknippa C Programming Language 6 23-Aug-2005 04:03
Download and register CAB file by IE! hvtin MS Visual C++ / MFC Forum 0 15-Apr-2005 04:40
Double output leanieleanz C++ Forum 1 11-Mar-2005 21:19

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:51.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.