如何删除链表接点并输出

[复制链接]
查看11 | 回复0 | 2008-5-11 10:14:40 | 显示全部楼层 |阅读模式
#include "stdio.h"#include "conio.h"#include "math.h"struct node{int data;struct node *next;};typedef struct node AA;AA *gz(){AA *h,*r,*b; int a;r=(AA *)malloc(sizeof(AA));h=r;printf("qing shu ru\n");scanf("%d",&a);while(a){ b=(AA *)malloc(sizeof(AA));b->data=a;r->next=b;r=b;scanf("%d",&a);}r->next=NULL;return h;}sh(){AA *to,*pp,*p,*t,*head=gz();p=t=head;//这里 t=t->next;while(t){if(t->data==30){p->next=t->next;//这里一部分 free(t);}p=t;t=t->next;}head=head->next;while(head){ printf("%d",head->data);head=head->next;}}main(){ sh(); getch(); }你对照着看看!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行