Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct elem
- {
- char prog[21],ceg[21];
- float szam;
- }ELEM;
- int rendez( const void *a, const void *b )
- {
- ELEM *pa = (ELEM * )a;
- ELEM *pb = (ELEM * )b;
- if ( (*pa).szam > (*pb).szam )
- return -1;
- else if ( (*pa).szam < (*pb).szam )
- return 1;
- else
- return strcmp((*pa).ceg,(*pb).ceg);
- }
- int main()
- {
- ELEM t[ 100 ];
- int index,i=0;
- char p[21],c[21];
- float sz;
- while( scanf("%s %s %f",p,c,&sz) != EOF )
- {
- strcpy( t[i].prog, p );
- strcpy( t[i].ceg, c );
- t[i].szam=sz;
- i++;
- }
- if(i<3) index=i;
- else index=3;
- qsort( t, i, sizeof( ELEM ), rendez );
- for ( i = 0; i<index ; ++i )
- printf( "%s %s %.1f\n", t[i].prog, t[i].ceg, t[i].szam );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement