将几个函数抽象为一个函数?每个函数只有其中的一个if判断条件不一样,实在不知道怎么弄

typedef struct school{
int schoolnum;
char schoolname[20];
int score;
int mscore;
int wscore;
item items[10];
struct school *next;
}school,*pschool;
//......................
int sscoreout()
{//指针冒泡
school *p,*q,*tail;
tail=NULL;
while(tail!=head->next)
{ p=head;
q=p->next;
while(q->next!=tail)
{
if(p->next->scorenext->score)//???
{p->next=q->next;
q->next=q->next->next;
p->next->next=q;
}
p=p->next;
q=p->next;
}
tail=q;
}
print(head->next);
return 0;
}
int mscoreout()
{
school *p,*q,*tail;
tail=NULL;
while(tail!=head->next)
{ p=head;
q=p->next;
while(q->next!=tail)
{
if(p->next->mscorenext->mscore)//???
{p->next=q->next;
q->next=q->next->next;
p->next->next=q;
}
p=p->next;
q=p->next;
}
tail=q;
}
print(head->next);
return 0;
}
int wscoreout()
{
school *p,*q,*tail;
tail=NULL;
while(tail!=head->next)
{ p=head;
q=p->next;
while(q->next!=tail)
{
if(p->next->wscorenext->wscore)//???
{p->next=q->next;
q->next=q->next->next;
p->next->next=q;
}
p=p->next;
q=p->next;
}
tail=q;
}
print(head->next);
return 0;
}

查看全部
qq_38682831
AaronLiu137
2017/05/21 01:33
  • 函数形参
  • 点赞
  • 收藏
  • 回答
    私信

1个回复