Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. void insertion_sort2(Student *tab, int n){
  2. Student pom;
  3. int j;
  4. for (int i = 1; i<n; i++){
  5. if (tab[i].month<=tab[i-1].month){
  6. if (tab[i].month<tab[i-1].month){
  7. pom=tab[i];
  8. for (j=i-1; (j>=0)&& tab[j].month>pom.month; j--)
  9. tab[j+1]=tab[j];
  10. tab[j+1] = pom;
  11. }
  12. else if (tab[i].month == tab[i-1].month){
  13. if (tab[i].grades<tab[i-1].grades){
  14. pom=tab[i];
  15. for (j=i-1; (j>=0)&& tab[j].grades>pom.grades; j--)
  16. tab[j+1]=tab[j];
  17. tab[j+1] = pom;
  18. }
  19. else if (tab[i].grades==tab[i-1].grades){
  20. if (tab[i].meters<tab[i-1].meters){
  21. pom=tab[i];
  22. for (j=i-1; (j>=0)&& tab[j].meters>pom.meters; j--)
  23. tab[j+1]=tab[j];
  24. tab[j+1] = pom;
  25. }
  26. else if (tab[i].meters==tab[i-1].meters){
  27. if (tab[i].number>tab[i-1].number){
  28. pom=tab[i];
  29. for (j=i-1; (j>=0)&& tab[j].number>pom.number; j--)
  30. tab[j+1]=tab[j];
  31. tab[j+1] = pom;
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement