链表需要帮助,求大佬指导

#include<stdio.h>
#include<stdlib.h>
typedef struct student
{
int xh;
char name[10];
int score[4];
struct student *link;
}STUDENT;
void Output (struct student *head);
struct student *Input(struct student *head);
main()
{
char n;
struct student *head=NULL;
printf("是否继续输入学生信息\n");
scanf(" %c",&n);
while(n=='y'||n=='Y')
{
head=Input(head);

printf("是否继续输入学生信息\n");
scanf(" %c",&n);
}
Output(head);
}
struct student *Input(struct student *head)
{
struct student *pr,*p=NULL,*q=head;//pr找前一个//
int i;
p=(struct student *)malloc(sizeof(struct student));
if(p==NULL)
{
printf("no enough memory");
exit(0);
}
scanf("%d%s",&(p->xh),p->name);
for(i=0;i<4;i )
scanf("%d",&(p->score[i]));
if(head==NULL) head=p;
else
{
while(q!=NULL)
{
pr=q;
q=q->link;
}
q->link=p;
p->link=NULL;
}
return head;
}
void Output (struct student *head)
{
struct student *p=head;
int i;
while(p!=NULL)
{
printf("%d,%s ",p->xh,p->name);
for(i=0;i<4;i )
printf("%d ",p->score[i]);
p=p->link;
}
return;
}
全部评论
点赞 回复 分享
发布于 2018-12-25 01:01
不想看,不能截图啊! 这样你给谁看啊?
点赞 回复 分享
发布于 2018-12-25 01:01

相关推荐

阿武同学:基本信息保留前面三行,其他的可以全部删掉,邮箱最重要的你没写,主修课程精简到8个以内,实习里面2/3/4都是水内容的,非要写的话建议两到三句话,项目经历排版优化下,自我评价缩到三行
点赞 评论 收藏
分享
刷牛客的我很豁达:你是不是对算法有什么误解,你没手握两篇顶刊顶会,还想搞算法岗,有顶刊顶会在算法岗算才入门
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务