我写了一上午,到底是哪里出错了呢?求高手帮帮忙!!
#include
#include
typedef char ElemType;
struct Node
{
ElemType data;
Node *next;
};
Node *head;
Node creatlist(Node *head) //创建链表
{
Node * p,*r;
char i;
head=new Node;
if (!head)
{
cout<<"分配内存失败!"<
head->next=NULL;
p=head;
cout<<"请输入数据:\n"<
while(i!='0')
{
p->data=i;
r=new Node;
r->next=p->next;
p->next=r;
p=r;
cin>>i;
}
return *r;
}
void output(Node *q) //输出数据
{
int j=0;
cout<<"要输出的数据:\n"<
if(!q)
{
cout<<"链表为空!"<
}
while (q->next)
{
cout<
q=q->next;
j++;
}
cout<
void combine(Node *s,Node *head)
{
while(s->next)
{
while(head->next)
{
if(head->data==s->data)
{
break;
}
else
{
cout<<"不是该集合的子集";
return;
}
}
s=s->next;
if(s->next)
{
cout<<"是该元素的子集";
}
}
}
void sk()//登录界面
{
cout<<"请选择您所要执行的操作"<
int a;
Node head1,head2;
cin>>a;
switch(a)
{
case 1:
{
cout<<"请输入要创建的集合名称"<
creatlist(head1);
sk();
break;
}
case 2:
{
cout<<"请输入要查看的集合"<
output(head1);
sk();
break;
}
case 3:
{
cout<<"请输入一个集合"<
sk();
break;
}
}
}
void main()
{
sk();
}