Thread: Sort Function

  1. #16
    Registered User
    Join Date
    Aug 2006
    I'm sorry I'm trying to understand what you're saying and trying to get it to work but I'm not understanding. Sorry.

  2. #17
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    New Zealand
    Alright, with various possibly conflicting things being said people have probably confused you, and you're over thinking things. This is about what you need I believe:
    template <class iterator>
       int sortPercentage(iterator start, iterator finish)
        int outOfOrder = 0;
        int numPairs = ...; // Simple subtraction equation here
        for (...)
            if (... > ...)
        return 100 * outOfOrder / numPairs;
    Other than the ... bits, I've left one other little math problem with it for you to correct. See what values you get from that for an already sorted and a reverse sorted array.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Compile problem: sort() cannot be used as a function!?
    By ac251404 in forum C++ Programming
    Replies: 2
    Last Post: 06-01-2006, 12:58 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Replies: 10
    Last Post: 09-15-2004, 01:00 PM