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