请大家帮忙翻译下这段程序?这段代码的实现功能是什么?怎么实现的?
void school_order(School *temp,int type) //type=0按总分,type=1按男总分,type=2按女总分,
{
School *p,*q,*small,*temp1;
temp1=new School;
temp1->next=NULL;
p=temp;
while(p)
{
small=p;
q=p->next;
while(q)
{
switch(type)
{
case 0:
if((q->boy+q->girl)<(small->girl+small->boy))
{
small=q;
}
break;
case 1:
if(q->boy<small->boy)
{
small=q;
}
break;
case 2:
if(q->girl<small->girl)
{
small=q;
}
break;
default:
cout<<"error"<<endl;
}
if(small!=p)
{
temp1->boy=p->boy;
p->boy=small->boy;
small->boy=temp1->boy;
temp1->girl=p->girl;
p->girl=small->girl;
small->girl=temp1->girl;
strcpy(temp1->name,p->name);
strcpy(p->name,small->name);
strcpy(small->name,temp1->name);
temp1->number=p->number;
p->number=small->number;
small->number=temp1->number;
}
q=q->next;
}
p=p->next;
}
}
[转载]下面的代码是怎么实现的?