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