#include<stdio.h>
#include<stdlib.h>
struct stu{
int num;
int scores;
struct stunext;};
struct stukiang(){
struct stu*head,*tail,p;
int num;
head=tail=NULL;
scanf("%d",&num);
while(num){
p=(struct stu)malloc(sizeof(struct stu));
scanf("%d",&p->num);
scanf("%d",&p->scores);
p->next=NULL;
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
num--;}
return head;}
int main(){
struct stu *head,*o,*p1,*p2;
int n;
scanf("%d",&n);
head=kiang();
p1=head;
p2=head->next;
if(head->num==n)
{o=head;
head=head->next;
}
while(p2!=NULL)
if(p2->num==n)
{p1->next=p2->next;
break;}
else
{p1=p2;
p2=p2->next;}
while(head!=NULL)
{printf("%d %d\n",head->num,head->scores);
head=head->next;}
return 0;}
能帮我看看我这个删除链表错在哪了吗
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- hello_world&& 2022-11-17 13:48关注
这三处均是指针,分别改为
struct stu *next;
*p;
p=(struct stu *)malloc解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥15 无源定位系统的时差估计误差标准差
- ¥15 请问这个代码哪里有问题啊
- ¥20 python--version在命令端输入结果Python is not defined怎么办?还有pip不是exe格式是不是没安装成功?
- ¥15 通过GaussianView进行结构微调消除虚频
- ¥15 调用transformers库
- ¥15 由于导出的数据名字中带有/,导致Matlab打不开,怎么办?
- ¥15 新硬盘安装的程序总是崩溃,提示遇到错误
- ¥15 openpcdet自制数据集评估bev精度和3d精度相同
- ¥15 excel 上下按钮 显示行
- ¥20 云卓h12pro 数传问题