Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- struct hallg
- {
- int pont;
- char nev[10];
- }hallg;
- int compare_by_name( const void *a, const void *b)
- {
- hallg *pa = (hallg *)a;
- hallg *pb = (hallg *)b;
- return strcmp( (*pa).nev , (*pb).nev );
- }
- int main() {
- struct hallg t[1000];
- int i=0,j,pont;
- char nev[10];
- while(scanf("%s %d", nev, &pont) != -1)
- {
- strcpy(t[i].nev , nev);
- t[i].pont = pont;
- i++;
- }
- qsort( t, i, sizeof( hallg ), compare_by_name);
- for(j=0;j<i;j++)
- printf("%s, %d\n",t[j].nev,t[j].pont);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement