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