C数据结构

来源:百度知道 编辑:UC知道 时间:2024/06/14 01:32:17
我有个程序希望好心的高手帮帮我
用链表实现一组字符的输入,之后只输出字符中小写字母a-z,其他都不输出,
输入两组字符,之后把两组字符做并交差的集合运算
帮帮小弟吧,真的算是救我一命啊 ,一点都不夸张 真的

C语言的呀
不好意思,C++写的可以吗?
#include<iostream>
using namespace std;
#include<stdio.h>
typedef struct node
{
char ch;
struct node *next;
}Node,*List;

void Init(List &list)
{
list=new Node;
list->ch='^';
list->next=NULL;
}
void Create(List &list)
{
char in;
in=getchar();
while(in!='\n') /* 以回车结束输入 */
{
List p=new Node;
p->ch=in;
p->next=list->next;/*插在表头,所以输出的时候是倒着输出的 */
list->next=p;
in=getchar();
}
}
void Print(const List list)
{
List p=list->next;
while(p)
{
if(p->ch>=97&&p->ch<=122) cout<<p->ch<<",";
p=p->next;
}
cout<<endl;
}
int main()
{
List list;
Init(list);
cout<<"enter the link list : "<<endl;
Create(li