#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    10
    Rep Power
    0

    I can not sort a pile.


    Hello everybody!

    Guys, I can not sort the stack. I created a new cell to house the numbers ordered, but she will see this as only houses where the largest number of the stack master. Someone please help me! Data structure is killing me!

    I'll just pass the function code:

    function sort

    library

    My logic was to find as many save the largest number in "bigger". Therein stack "stack" was empty so I use the stack "pilhaAux" to stack the numbers in "stack" but if you think the greatest, not including the stack "stack."

    Suggestions are very welcome!
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    149
    Rep Power
    37
    Are you only allowed to use a stack? It is hard to help you if you don't specify the constraints of your assignment.
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,855
    Rep Power
    481
    Code:
    TStackKey top(TStack s){
      if (!emptystack(s))
        return s.keys[s.depth - 1];
    }
    You have several functions that choose a specific return value within an if statement. I think you need to choose a return value when emptystack(s) is true. A gnu c extension automatically returns the last expression result computed before the function returns.
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    10
    Rep Power
    0
    My intention is to create a function that takes a stack and print it ordered, no matter what. As you may have seen, it is a static pile. You can still help me?
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,855
    Rep Power
    481
    Stick your stack into an array (maybe it already is?) and call qsort
    (man qsort)
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo