Ĺadny brzuch
struct hotel
{
int cena;
int odl;
};
vector<hotel> w
Zadeklarowałem wektor tak jak wyżej!
Jak mam go posortować według odl?
bool sortuj(const hotel& x, const hotel& y){ return x.odl<y.odl; } ... sort(w.begin(), w.end(), sortuj);
class cmp { public: bool operator () ( const hotel& h1, const hotel& h2 ) { return (h1.odl < h2.odl) ? true : false; } }; std::sort(w.begin(), w.end(),cmp() );
Użytkownik Artur Menc edytował ten post 15 wrzesień 2007, 22:28
zanotowane.pl doc.pisz.pl pdf.pisz.pl zsf.htw.pl
Zadeklarowałem wektor tak jak wyżej!
Jak mam go posortować według odl?
bool sortuj(const hotel& x, const hotel& y){ return x.odl<y.odl; } ... sort(w.begin(), w.end(), sortuj);
class cmp { public: bool operator () ( const hotel& h1, const hotel& h2 ) { return (h1.odl < h2.odl) ? true : false; } }; std::sort(w.begin(), w.end(),cmp() );
Użytkownik Artur Menc edytował ten post 15 wrzesień 2007, 22:28