请大家帮忙翻译下这段程序?这段代码的实现功能是什么?怎么实现的?
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;
}
}
----------------解决方案--------------------------------------------------------
这就要知道School这个结构怎样定义,才能使用.
----------------解决方案--------------------------------------------------------
{
char name[20];
int boy;
int gril;
school *next;
}
弄不懂.
----------------解决方案--------------------------------------------------------
对指针不懂
----------------解决方案--------------------------------------------------------
typedef struct School //学校结构
{
char name[20]; //学校名称
int number; //学校编号
int boy; //男子团体总分
int girl; //女子团体总分
School *next;
}School;
----------------解决方案--------------------------------------------------------