fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <string.h>
  4.  
  5. typedef struct thongtin {
  6. char msv[50];
  7. char hoten[50];
  8. char lop[50];
  9. double mon1,mon2,mon3;
  10. }tt;
  11.  
  12. int comparebyname(const void *s1, const void *s2) {
  13. return strcmp(((tt*)s1) -> msv,((tt*)s2) -> msv);
  14. }
  15.  
  16. int main() {
  17. tt a[100];
  18. int n;
  19. scanf("%d",&n);
  20. for(int i=0;i<n;i++) {
  21. scanf("\n");
  22. gets(a[i].msv);
  23. gets(a[i].hoten);
  24. gets(a[i].lop);
  25. scanf("\n");
  26. scanf("%lf",&a[i].mon1);
  27. scanf("%lf",&a[i].mon2);
  28. scanf("%lf",&a[i].mon3);
  29. }
  30. qsort(a,n,sizeof(tt),comparebyname);
  31. for(int i=0;i<n;i++) {
  32. printf("%d %s %s %s %.1lf %.1lf %.1lf\n",i+1,a[i].msv,a[i].hoten,a[i].lop,a[i].mon1,a[i].mon2,a[i].mon3);
  33. }
  34. }
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty