题目:
已知1个单链表的data域为字符型数据,试编写算法,构造3个带表头结点的单循环链表
使这3个循环链表分别存放原单链表中的字母字符,数字字符和其它字符。
#include<stdio.h>
typedef struct node *pointer,*lklist;
lklist head,a,b,c;
pointer p,q;
void initiate(lklist h)
{
h=(pointer)malloc(sizeof(struct node));
h->next=0;
}
lklist setup1(lklist head)
{
char x;
head=(pointer)malloc(sizeof(struct node));
head->next=0;
p=head;
scanf("%c",&x);
while(x!='*')
{
q=(pointer)malloc(sizeof(struct node));
q->data=x;
p->next=q;
p=q;
scanf("%c",&x);
}
p->next=0;
return head;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余4页未读,立即下载