为什么老是出错?请帮我分析一下错误//成绩排名#include#includestruct chengji{char name[10];float fenshu;chengji *next;};void main(){chengji *head;int n;void create(chengji*&,int);coutn;create(head,n);void f(chengji *&,int);f(head,n);

来源:学生作业帮助网 编辑:作业帮 时间:2024/12/01 04:51:29
为什么老是出错?请帮我分析一下错误//成绩排名#include#includestruct chengji{char name[10];float fenshu;chengji *next;};void main(){chengji *head;int n;void create(chengji*&,int);coutn;create(head,n);void f(chengji *&,int);f(head,n);
xUn@KH( Sޜ ?P$6v/*hYJJ@TRQn "zױ $$-3gf0evbNeEmuVY [1Xt:Um؃V%jl]b1#{|!WL*rZr.- "y(2.e $iz$ZTYʈ^tOd G>vǺ tąף^B1[ed|yWW0yĕqqE!pQ!WdG+\PͧCG]kD}IS 2bɎey* -E\<:=_Cc-{LwYOWwtzho*-@oF!f]~5E@ @K^\ARR*,BMR)ϓNe(q{ Oz0AU FşI lUilf)p yaHV40J"Z?^۰hevLب]yGU<&ZEO~5İZXW,/+N&DS"3QHu 7{m?av )@?J4$`-%/3c61‘|ɅbNԠ7_asAf^JW3xg+pvη14m8ΈZ2" un5

为什么老是出错?请帮我分析一下错误//成绩排名#include#includestruct chengji{char name[10];float fenshu;chengji *next;};void main(){chengji *head;int n;void create(chengji*&,int);coutn;create(head,n);void f(chengji *&,int);f(head,n);
为什么老是出错?请帮我分析一下错误
//成绩排名
#include
#include
struct chengji{
char name[10];
float fenshu;
chengji *next;
};
void main()
{
chengji *head;int n;
void create(chengji*&,int);
coutn;
create(head,n);
void f(chengji *&,int);
f(head,n);
void out(chengji*&);
out(head);
}
void create(chengji *&h,int m){ //对于只要3、4个成绩的情况就没有必要用程序排名
chengji *p,*pp;
h=new chengji;p=h;
coutname,a);
for(int i=1;i>a>>x;pp=new chengji;strcpy(pp->name,a);pp->fenshu=x;
p->next=pp;p=pp;
}p->next=NULL;
}
void f(chengji *&hh,int mm){
char aa[10];float y;
chengji *f1,*f2;
for(int j=1;jfenshufenshu)
{strcpy(aa,f1->name);
strcpy(f1->name,f2->name);
strcpy(f2->name,aa);
y=f1->fenshu;
f1->fenshu=f2->fenshu;
f2->fenshu=y;}
f1=f2;
}
}
}
void out(chengji *&h1){
chengji *h2=h1;int kk=1;
do{cout

为什么老是出错?请帮我分析一下错误//成绩排名#include#includestruct chengji{char name[10];float fenshu;chengji *next;};void main(){chengji *head;int n;void create(chengji*&,int);coutn;create(head,n);void f(chengji *&,int);f(head,n);
帮你修改运行过了,好好看看吧.
#include
#include
struct chengji{
char name[10];
float fenshu;
chengji *next;
};
chengji *create(int m); //子函数定义放在主函数后面定义,主义要先声明
chengji *f(chengji *hh,int mm);
void out(chengji *h1,int n);
void main()
{
chengji *head;int n;
coutn;
head=create(n);
head=f(head,n);
coutname,a);pp->fenshu=x;
if(i==0) //创建头结点数据
{
h=p;
couth->name;
couth->fenshu;}
else
{
pp->next=p;
coutp->name;
coutp->fenshu;
}
pp=p;
}
pp->next=NULL;
return h;
}
chengji *f(chengji *hh,int mm) //成绩排序,返回排序后链表头结点
{
char aa[10];float y;
chengji *f1,*f2,*f3=hh;
for(int j=1;jfenshu>f2->fenshu)
{strcpy(aa,f1->name);
strcpy(f1->name,f2->name);
strcpy(f2->name,aa);
y=f1->fenshu;
f1->fenshu=f2->fenshu;
f2->fenshu=y;}
}
}
return f3;
}
void out(chengji *head,int n) //输出班级
{
chengji *p1=head;
for(int i=0;i