p35 实验二 删除奇数结点的链表-----程序实现
求解方法有2种:
- 第一种是用2个链表A和B,从A中寻找偶数结点,把它链到B链表中,最后输出B链表。参考教材p33。
- 第二种是在一个链表中完成删除奇数结点的操作。目前该程序已经写好,打算下周发布在该网页上。
很多同学出现的错误多发生在 如下语句中。请参考思考
完整程序如下:
1 : #include <iostream.h>
2 : #include <stdlib.h>
3 :
4 : struct Node
5 : {
6 : int data;
7 : struct Node *next;
8 : };
9 :
10 : struct Node *CreatListF()//用头插法建立单链表
11 : {
12 : int ch;
13 : struct Node *H=NULL; //链表头指针开始为空
14 : struct Node *p; //工作指针
15 : // ch=getchar(); //读入第1个