typedef struct {
    const char *name, *id, *dept;
    int sal;
} person;

person ppl[] = {
    {,   , , 32000},
    {,      , , 47000},
    {,  , , 53500},
    {,      , , 18000},
    {,  , , 27800},
    {, , , 41500},
    {,    , , 49500},
    {,    , , 21900},
    {,  , , 15900},
    {, , , 19250},
    {,     , , 27000},
    {,      , , 57000},
    {,   , , 29900},
};

int pcmp(const void *a, const void *b)
{
    const person *aa = a, *bb = b;
    int x = strcmp(aa->dept, bb->dept);
    if (x) return x;
    return aa->sal > bb->sal ? -1 : aa->sal < bb->sal;
}


void top(int n)
{
    int i, rank;
    qsort(ppl, N, sizeof(person), pcmp);

    for (i = rank = 0; i < N; i++) {
        if (i && strcmp(ppl[i].dept, ppl[i - 1].dept)) {
            rank = 0;
            printf();
        }

        if (rank++ < n)
            printf(, ppl[i].dept, ppl[i].sal, ppl[i].name);
    }
}

int main()
{
    top(2);
    return 0;
}