用编程编制一个学生成绩信息表,以链表的形式存放怎么编啊?
答案:1 悬赏:30 手机版
解决时间 2021-05-09 13:18
- 提问者网友:树红树绿
- 2021-05-08 23:06
用编程编制一个学生成绩信息表,以链表的形式存放怎么编啊?
最佳答案
- 五星知识达人网友:往事隔山水
- 2021-05-09 00:20
#define max 30;
int i,j,k;
char m;
struct student
{
int classnumber;
int number;
char name[20];
int grade;
student *next;
};
student *head;
student *taxis(student *x);
student *create(int i);
void main()
{
student *range=NULL;
student *m=NULL;
cout<<"输入班级号码:"<<endl;
cin>>i;
m=create(i);
range=taxis(m);
while(range!=NULL)
{
cout<<range->number<<'\t'<<range->name<<'\t'<<range->grade<<endl;
range=range->next;
}
}
student *create(int i)
{
student *head3=NULL;
student *head4=NULL;
head=NULL;
int number1;
cout<<"输入学生学号:(0表示输入结束)"<<endl;
cin>>number1;
while(number1!=0)
{
head3=new student;
head3->classnumber=i;
head3->number=number1;
cout<<"输入姓名:"<<endl;
cin>>head3->name;
cout<<"输入成绩:"<<endl;
cin>>head3->grade;
if(head==NULL)
{
head=head3;
}
else
{
head4->next=head3;
}
head4=head3;
cout<<"输入学生学号:(0表示输入结束)"<<endl;
cin>>number1;
}
if(head!=NULL)
head4->next=NULL;
return head;
}
student *taxis(student *mm)
{
int i=1;
student *head5=NULL;
student *head6=NULL;
student *head7=NULL;
student *flag=NULL;
student *p=NULL;
student *q=NULL;
head5=mm;
head6=mm->next;
flag=mm;
while(flag!=NULL)
{
p=new student;
if(i==1)
{
q=p;
i++;
}
while(head6!=NULL)
{
head7=head5;
if(head5->grade < head6->grade)
{
head5=head6;
}
head6=head6->next;
}
if(p==NULL)
{
p=head5;
}
else
{
p->next=head5;
}
if(head7!=mm)
{
head7->next=head5->next;
}
flag=flag->next;
}
p->next=NULL;
return q;
}
大概就是这样了
你看看书
0
int i,j,k;
char m;
struct student
{
int classnumber;
int number;
char name[20];
int grade;
student *next;
};
student *head;
student *taxis(student *x);
student *create(int i);
void main()
{
student *range=NULL;
student *m=NULL;
cout<<"输入班级号码:"<<endl;
cin>>i;
m=create(i);
range=taxis(m);
while(range!=NULL)
{
cout<<range->number<<'\t'<<range->name<<'\t'<<range->grade<<endl;
range=range->next;
}
}
student *create(int i)
{
student *head3=NULL;
student *head4=NULL;
head=NULL;
int number1;
cout<<"输入学生学号:(0表示输入结束)"<<endl;
cin>>number1;
while(number1!=0)
{
head3=new student;
head3->classnumber=i;
head3->number=number1;
cout<<"输入姓名:"<<endl;
cin>>head3->name;
cout<<"输入成绩:"<<endl;
cin>>head3->grade;
if(head==NULL)
{
head=head3;
}
else
{
head4->next=head3;
}
head4=head3;
cout<<"输入学生学号:(0表示输入结束)"<<endl;
cin>>number1;
}
if(head!=NULL)
head4->next=NULL;
return head;
}
student *taxis(student *mm)
{
int i=1;
student *head5=NULL;
student *head6=NULL;
student *head7=NULL;
student *flag=NULL;
student *p=NULL;
student *q=NULL;
head5=mm;
head6=mm->next;
flag=mm;
while(flag!=NULL)
{
p=new student;
if(i==1)
{
q=p;
i++;
}
while(head6!=NULL)
{
head7=head5;
if(head5->grade < head6->grade)
{
head5=head6;
}
head6=head6->next;
}
if(p==NULL)
{
p=head5;
}
else
{
p->next=head5;
}
if(head7!=mm)
{
head7->next=head5->next;
}
flag=flag->next;
}
p->next=NULL;
return q;
}
大概就是这样了
你看看书
0
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯