1.知识点:链表的查询、插入
2.题意:输入N个整数顺序建立一个单链表,将该单链表拆分成两个子链表,第一个子链表存放了所有的偶数,第二个子链表存放了所有的奇数。两个子链表中数据的相对次序与原链表一致
3.注意事项:注意单链表节点全为奇数节点或全为偶数节点的情况
代码:
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
struct node *creat(int n)/*逆序建立链表*/
{
int i;
struct node *head,*p;
head=(struct node *)malloc(sizeof(struct node));
head->next=NULL;
for(i=0; i&