永发信息网

编译错误,为什么 #include<stdio.h> #include<stdlib.h> struct student { int n;char name[

答案:2  悬赏:0  手机版
解决时间 2021-02-12 00:15
编译错误,为什么
#include
#include
struct student
{
int n;char name[100];
int score;
struct student *next;
};
int main()
{
struct student *head,*p,*q,a;
int i=3;
head=NULL;
for(p=head;i>0;i--,p=p->next)
scanf("%d%s%d",&p->n,p->name,&p->score);

p->next=NULL; scanf("%d%s%d",&a.n,a.name,&a.score);
for(p=head,q=p->next;q!=NULL;){
if(q->n>a.n){
p->next=&a;
p=p->next;
p->next=q;
}
p=p->next;q=q->next;
}
for(p=head;p->next!=NULL;p=p->next)
printf("%d\n%s\n%d\n",p->n,p->name,p->score);
}
最佳答案
#include

struct student//////////结构体定义

{int no;
float grade;
struct student *next;};
int n;

struct student*head,*p;

struct student*creat()//////////定义输入函数
{
struct student*head;

struct student*p1,*p2;

n=0;
p1=p2=(struct student*)malloc(sizeof(struct student)); //这里要加强制转换
scanf(" %ld,%f",&p1->no,&p1->grade);

head=NULL;
while(p1->no!=0)
{n=n+1;

if(n==1)
head=p1;
else p2->next=p1;

p2=p1;
p1=(struct student*)malloc(sizeof(struct student));//这里要加强制转换
scanf(" %ld,%f",&p1->no,&p1->grade);//sco改为grade
}

p2->next=NULL;
全部回答
int n ; 学号/编号 char name[10] ; 姓名 int score ; 分数 struct student st[n]; 定义n个学生结构体变量 scanf(“%d%s%d”, &st[i].n , st[i].name, &st[i].score) ;依次输入学生的学号,姓名与分数
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
如果一个男孩对一个女孩说我想要你啥意思
1987年公历(身份证上11月11日)农历是九月廿
全球卓著英语培训专家(燕儿岛支路)地址在什么
the tv play is not interesting enough to w
谁有ms office2010激活码???求助!!朋友
哪本小说男主叫霍辰东
男人胳膊上有几个骨头组成
懒二喵地址在哪,我要去那里办事
黄色银杏叶蒸后晒干·泡水喝行吗?
亲哥哥和自己的老婆是什么称谓关系
弥散成像是什么意思
95%浓度的酒精可以拔罐么?
兴隆社区居民之家地址在哪,我要去那里办事
关于该药中毒后的处理,下列说法不正确的为A.
迅游免费帐号可以用影子系统无限用么?~
推荐资讯
日本电脑cf-57进入bios界面都是日文怎么装系
万宝小区西门(人行门)在什么地方啊,我要过去
绿海花园我想知道这个在什么地方
初中所学的欧阳修的作品都有什么?
网络预约出租汽车平台公司应当保证提供服务的
形容“体格”的词语有哪些?
45%用英语怎么读
女强现代重生术士风水看相小说,不是重生的也
我在老家起诉离婚了,现在快到开庭时间了,我
2014款轩逸多少钱
药品销售的大区经理具体都要做些什么?
芜湖鼎膳餐饮管理有限公司地址在哪,我要去那
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?