Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

sorting of structure

$
0
0

struct contestant
{

int prob,time;
bool operator < (const struct contestant &c ) const
{
    if( this->prob > c.prob ) return 1;
    else if( this->prob == c.prob)
    {
        if( this->time <= c.time ) return 1;
        return 0;
    }
    return 0;
}

} con[1000];

when i applly library sort function sort(con,con+size) when storing elements in structure from 0...size-1 it works fine when same sort function used like sort(con+1,con+size+1) when storing elements in structure con from 1...size works incorrectly... any help please... thanks in advance...


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>