满意答案
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语言编程编写程序 建立一个学生数据链表 学生的数据包括学号 姓名 成绩。...