Ask Your Question
1

Třídění qsort

asked 2014-11-27 16:17:15 +0100

anonymous user

Anonymous

updated 2014-11-27 22:45:08 +0100

anonymous user

Anonymous

Jak seřadit pomocí qsort strukturu podle 2 kritérii např data 12.1,20.5,28.10

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
3

answered 2014-11-27 16:43:09 +0100

Viktor Chlumský gravatar image

Obě kritéria můžete zahrnout do srovnávací funkce, kterou dáváte qsortu. Měla by vypadat nějak takto (pseudokód):

int compare(const void *a, const void *b) {
    if (1. kritérium je stejné) {
        return porovnání 2. kritéria
    }
    return porovnání 1. kritéria
}
edit flag offensive delete publish link more

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

Add answer

[hide preview]

Stats

Asked: 2014-11-27 16:17:15 +0100

Seen: 83 times

Last updated: Nov 27 '14