1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > C语言创建学生姓名分数链表 C语言编程 编写程序 建立一个学生数据链表 学生的数据

C语言创建学生姓名分数链表 C语言编程 编写程序 建立一个学生数据链表 学生的数据

时间:2018-08-25 11:25:31

相关推荐

C语言创建学生姓名分数链表 C语言编程 编写程序 建立一个学生数据链表 学生的数据

满意答案

w6611826

.04.19

采纳率:50%等级:11

已帮助:10597人

#include

#include

#define NULL 0

struct stud

{

int no;

char name[12];

int age;

struct stud*next;

};

#define LEN sizeof(struct stud)

struct stud*creat(void)

{

struct stud*p1,*p2,*head;

int n=0;

p1=(struct stud*)malloc(LEN);

scanf("%d%s%d",&p1->no,p1->name,&p1->age);

while(p1->no>0){

n++;

if(n==1){head=p1;p2=p1;}

else{p2->next=p1;p2=p1;}

p1=(struct stud*)malloc(LEN);

scanf("%d",&p1->no);

if(p1->no==0)break;

scanf("%s%d",p1->name,&p1->age);

}

p2->next=NULL;

return head;

}

void main()

{

struct stud*del(struct stud*head,int no);

int num;

struct stud*p,*p0;

p0=creat();

scanf("%d",&num);

p=del(p0,num);

print(p);

}

struct stud*del(struct stud*head,int num)

{

struct stud *p1,*p2;

p1=head;

while(p1->next!=NULL){

if(p1->no==num) break;

p2=p1;

p1=p1->next;

}

if(p1==head){

p1->next=head;

}

else {

p2->next=p1->next;

}

return head;

}

24分享举报

C语言创建学生姓名分数链表 C语言编程编写程序 建立一个学生数据链表 学生的数据包括学号 姓名 成绩。...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。