fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct{
  4. int ID;
  5. int weight;
  6. int height;
  7. }Body;
  8.  
  9. void swap(Body *b);
  10.  
  11. int main(void) {
  12.  
  13. Body a[] = {
  14. {1,65,169},
  15. {2,73,173},
  16. {3,59,161},
  17. {4,79,175},
  18. {5,55,168}
  19. };
  20.  
  21. swap(a);
  22. for(int i=0;i<5;i++){
  23. printf("%d %d %d\n",a[i].ID,a[i].weight,a[i].height);
  24. }
  25. return 0;
  26. }
  27. void swap(Body *b)
  28. {
  29. Body x;
  30. for(int i=0;i<5;i++){
  31. for(int j=i+1;j<5;j++){
  32. if(b[i].height<b[j].height){
  33. x=b[i];
  34. b[i]=b[j];
  35. b[j]=x;
  36. }
  37. }
  38. }
  39. }
  40.  
  41.  
  42.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
4 79 175
2 73 173
1 65 169
5 55 168
3 59 161