Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. sort linklist problem

sort linklist problem

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arif Liminto
    wrote on last edited by
    #1

    hi i got a problem with sort linklist in c i confuse how to swap the number in linklist basicly i use selection sort and "top is global variable that store unsorted linklist and i want to make it sorted" how ever icannot make it sort can u guys help me? thanks void sortQ() { myQue *sq,*ft; sq = top; myQue *temp; myQue *min = top; while((sq != NULL) { min = sq; ft = sq->nextQ; while(ft != NULL) { if(ft->total < min->total) min = ft; ft = ft->nextQ; } //swap mode on temp = sq; sq->nextQ = min->nextQ; min = temp; sq = sq->nextQ; } }

    T H D 3 Replies Last reply
    0
    • A Arif Liminto

      hi i got a problem with sort linklist in c i confuse how to swap the number in linklist basicly i use selection sort and "top is global variable that store unsorted linklist and i want to make it sorted" how ever icannot make it sort can u guys help me? thanks void sortQ() { myQue *sq,*ft; sq = top; myQue *temp; myQue *min = top; while((sq != NULL) { min = sq; ft = sq->nextQ; while(ft != NULL) { if(ft->total < min->total) min = ft; ft = ft->nextQ; } //swap mode on temp = sq; sq->nextQ = min->nextQ; min = temp; sq = sq->nextQ; } }

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      before helping you, here is some step I would like to follow when posting on this board : 1. speak english ("u" is not correct english, "you" is ; use punctuation, and space your words). 2. when posting code, put it inside <pre></pre> tags so that everybody can benefit of the indentation. 3. in a general mean, follow the forum guidelines[^] dicted by the admin. now, please edit your post (not repost a new one) and your post will hopefully get the help it deserves.


      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      1 Reply Last reply
      0
      • A Arif Liminto

        hi i got a problem with sort linklist in c i confuse how to swap the number in linklist basicly i use selection sort and "top is global variable that store unsorted linklist and i want to make it sorted" how ever icannot make it sort can u guys help me? thanks void sortQ() { myQue *sq,*ft; sq = top; myQue *temp; myQue *min = top; while((sq != NULL) { min = sq; ft = sq->nextQ; while(ft != NULL) { if(ft->total < min->total) min = ft; ft = ft->nextQ; } //swap mode on temp = sq; sq->nextQ = min->nextQ; min = temp; sq = sq->nextQ; } }

        H Offline
        H Offline
        Hans Dietrich
        wrote on last edited by
        #3

        And one more thing: stop cross posting.

        1 Reply Last reply
        0
        • A Arif Liminto

          hi i got a problem with sort linklist in c i confuse how to swap the number in linklist basicly i use selection sort and "top is global variable that store unsorted linklist and i want to make it sorted" how ever icannot make it sort can u guys help me? thanks void sortQ() { myQue *sq,*ft; sq = top; myQue *temp; myQue *min = top; while((sq != NULL) { min = sq; ft = sq->nextQ; while(ft != NULL) { if(ft->total < min->total) min = ft; ft = ft->nextQ; } //swap mode on temp = sq; sq->nextQ = min->nextQ; min = temp; sq = sq->nextQ; } }

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          arifliminto86 wrote:

          //swap mode on temp = sq; sq->nextQ = min->nextQ; min = temp;

          The general format of any swap routine is: A = B B = C C = A


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups