- 论坛徽章:
- 0
|
#include<iostream.h>;
struct student
{
int ladder;
int number;
float time;
student *next;
};
student *head;
void insert(student *_point)
{
if(_point->;time<=head->;time)
{
_point->;next=head;
head=_point;
return;
}
student *q,*r;
q=head;
do
{
r=q;
q=q->;next;
if(q=NULL)
{
r->;next=_point;
_point->;next=NULL;
return;
}
}while(_point->;time<=q->;time) ;
r->;next=_point;
_point->;next=q;
return;
}
void main()
{
student *p=NULL;
student *q=NULL;
head=NULL;
for (int ii=0;ii<=8;ii++)
{
p=new student;
cin>;>;p->;ladder>;>;p->;number>;>;p->;time;
q=p;
if (head==NULL)
{
head=p;
}
p=p->;next;
}
student *_cout;
_cout=head;
do
{
cout<<_cout->;number;
_cout=_cout->;next;
}while(cout!=NULL);
student *point=NULL;
for (ii=0;ii<=8;ii++)
{
point=new student;
cin>;>;point->;ladder>;>;point->;number>;>;point->;time;
insert(point);
}
_cout=head;
do
{
cout<<_cout->;number;
_cout=_cout->;next;
}while(cout!=NULL);
}
13.某次国际田径邀请赛,100m赛跑项目有16位选手分两组进行。
第一组8位选手的成绩如下:
运动员号码 207 156 453 096 338 136 501 614
成绩:秒 10.28 11.02 10.54 10.98 10.63 11.04 11.23 11.08
请你先将第一组的成绩形成一个链表,成绩好的在前面,差的排在后面。每个结点有三个数据:①名次,②运动员号码,③成绩。
当第二组8位选手的成绩得到后请将其中的每一名选手依成绩的好坏插入到链表当中。第二组成绩如下:
运动员号码 209 181 461 059 121 525 606 320
成绩:秒 10.11 11.12 11.00 10.99 11.50 11.40 10.22 10.65
最后从头到尾输出链表中结点的数据。
输入:有16行,每行两个数字,一个整数,一个小数,分别表示运动员号码和成绩。
输出:两行,第一行是第一组选手按照成绩排序输出的运动员编号(8位选手);第二行是第二组插入链表后,按成绩排序输出的运动员编号(16位选手)。每两个运动员编号之间用空格隔开。
这是题目,不知怎么回事,执行后,添加几个人的数据就出错~~帮忙看看,各位大哥 |
|