Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void insertion_sort2(Student *tab, int n){
- Student pom;
- int j;
- for (int i = 1; i<n; i++){
- if (tab[i].month<=tab[i-1].month){
- if (tab[i].month<tab[i-1].month){
- pom=tab[i];
- for (j=i-1; (j>=0)&& tab[j].month>pom.month; j--)
- tab[j+1]=tab[j];
- tab[j+1] = pom;
- }
- else if (tab[i].month == tab[i-1].month){
- if (tab[i].grades<tab[i-1].grades){
- pom=tab[i];
- for (j=i-1; (j>=0)&& tab[j].grades>pom.grades; j--)
- tab[j+1]=tab[j];
- tab[j+1] = pom;
- }
- else if (tab[i].grades==tab[i-1].grades){
- if (tab[i].meters<tab[i-1].meters){
- pom=tab[i];
- for (j=i-1; (j>=0)&& tab[j].meters>pom.meters; j--)
- tab[j+1]=tab[j];
- tab[j+1] = pom;
- }
- else if (tab[i].meters==tab[i-1].meters){
- if (tab[i].number>tab[i-1].number){
- pom=tab[i];
- for (j=i-1; (j>=0)&& tab[j].number>pom.number; j--)
- tab[j+1]=tab[j];
- tab[j+1] = pom;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement