Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. struct hallg
  6. {
  7. int pont;
  8. char nev[10];
  9. }hallg;
  10.  
  11. int compare_by_name( const void *a, const void *b)
  12. {
  13. hallg *pa = (hallg *)a;
  14. hallg *pb = (hallg *)b;
  15. return strcmp( (*pa).nev , (*pb).nev );
  16. }
  17.  
  18. int main() {
  19. struct hallg t[1000];
  20. int i=0,j,pont;
  21. char nev[10];
  22.  
  23. while(scanf("%s %d", nev, &pont) != -1)
  24. {
  25. strcpy(t[i].nev , nev);
  26. t[i].pont = pont;
  27. i++;
  28. }
  29. qsort( t, i, sizeof( hallg ), compare_by_name);
  30. for(j=0;j<i;j++)
  31. printf("%s, %d\n",t[j].nev,t[j].pont);
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement