用c语言写两个程序,1,集合的交并差运算.2,计算关系的闭包(3种)不要求功能非常完备,能实现最基本的就行,采纳了把我所有的都给你,四百分

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/06 00:50:19
用c语言写两个程序,1,集合的交并差运算.2,计算关系的闭包(3种)不要求功能非常完备,能实现最基本的就行,采纳了把我所有的都给你,四百分

用c语言写两个程序,1,集合的交并差运算.2,计算关系的闭包(3种)不要求功能非常完备,能实现最基本的就行,采纳了把我所有的都给你,四百分
用c语言写两个程序,1,集合的交并差运算.2,计算关系的闭包(3种)不要求功能非常完备,能实现最基本的就行,采纳了把我所有的都给你,四百分

用c语言写两个程序,1,集合的交并差运算.2,计算关系的闭包(3种)不要求功能非常完备,能实现最基本的就行,采纳了把我所有的都给你,四百分
第一个程序
集合的交并差运算
#include
#include
typedef struct pointer{
char dat;
struct pointer *link;
} pointer;
void readdata(pointer *head){ //读集合
pointer *p;
char tmp;
printf("input data ('0' for end):");
scanf("%c",&tmp);
while(tmp!='0')
{
if((tmp'z'))
{
printf("输入错误!必须为小写字母!\n");
return;
}
p=(pointer *)malloc(sizeof(struct pointer));
p->dat=tmp;
p->link=head->link;
head->link=p;
scanf("%c",&tmp);
}
}
void disp(pointer *head){ //显示集合数据
pointer *p;
p=head->link;
while(p!=NULL)
{
printf("%c ",p->dat);
p=p->link;
}
printf("\n");
}
void bing(pointer *head1,pointer *head2,pointer *head3){ //计算集合1与集合2的并
pointer *p1,*p2,*p3;
p1=head1->link;
while(p1!=NULL)
{
p3=(pointer *)malloc(sizeof(struct pointer));
p3->dat=p1->dat;
p3->link=head3->link;
head3->link=p3;
p1=p1->link;
}
p2=head2->link;
while(p2!=NULL)
{
p1=head1->link;
while((p1!=NULL)&&(p1->dat!=p2->dat))
p1=p1->link;
if(p1==NULL)
{
p3=(pointer *)malloc(sizeof(struct pointer));
p3->dat=p2->dat;
p3->link=head3->link;
head3->link=p3;
}
p2=p2->link;
}
}
void jiao(pointer *head1,pointer *head2,pointer *head3){ //计算集合1与集合2的交
pointer *p1,*p2,*p3;
p1=head1->link;
while(p1!=NULL)
{
p2=head2->link;
while((p2!=NULL)&&(p2->dat!=p1->dat))
p2=p2->link;
if((p2!=NULL)&&(p2->dat=p1->dat))
{
p3=(pointer *)malloc(sizeof(struct pointer));
p3->dat=p1->dat;
p3->link=head3->link;
head3->link=p3;
}
p1=p1->link;
}
}
void cha(pointer *head1,pointer *head2,pointer *head3){ //计算集合1与集合2的差
pointer *p1,*p2,*p3;
p1=head1->link;
while(p1!=NULL)
{
p2=head2->link;
while((p2!=NULL)&&(p2->dat!=p1->dat))
p2=p2->link;
if(p2==NULL)
{
p3=(pointer *)malloc(sizeof(struct pointer));
p3->dat=p1->dat;
p3->link=head3->link;
head3->link=p3;
}
p1=p1->link;
}
}
main(){
pointer *head1,*head2,*head3;
head1=(pointer *)malloc(sizeof(struct pointer));
head1->link=NULL;
head2=(pointer *)malloc(sizeof(struct pointer));
head2->link=NULL;
head3=(pointer *)malloc(sizeof(struct pointer));
head3->link=NULL;
printf("输入集合1:\n");
readdata(head1);
printf("输入集合2:\n");
readdata(head2);
printf("集合1为:\n");
disp(head1);
printf("集合2为:\n");
disp(head2);
printf("集合1与集合2的并为:\n");
bing(head1,head2,head3);
disp(head3);
head3->link=NULL;
printf("集合1与集合2的交为:\n");
jiao(head1,head2,head3);
disp(head3);
head3->link=NULL;
printf("集合1与集合2的差为:\n");
cha(head1,head2,head3);
disp(head3);
}
测试用例为(0表示集合输入结束):
fdsa0
savc0
第二个程序
计算关系的闭包(3种)
#include
void output(int s[][100]);
void zifan(int s2[][100]);
void duichen(int s2[][100]);
void chuandi2(int s2[][100]);
void chuandi1(int s2[][100]);
void aa();
int s[100][100],z;
int d,n ,i,j;
int main(){aa();return 0;}
void aa()
{
printf("请输入矩阵的行数(必须小于10)\n ");
scanf("%d",&n);
printf("请输入矩阵的列数(必须小于10)\n ");
scanf("%d",&d);
printf("请输入关系矩阵\n");
for(i=0;i

用c语言写两个程序,1,集合的交并差运算.2,计算关系的闭包(3种)不要求功能非常完备,能实现最基本的就行,采纳了把我所有的都给你,四百分 数据结构 用c语言写的 集合的并、交和差运算的程序基本要求:(1)集合的元素限定为小写字母字符〔‘a’..'z'〕.(2)演示程序以用户和计算机的对话方式执行.实现提示:以有序链表表示 编写程序,实现两个集合的交运算(用C语言)1、已知两个整数集合中的数据以递增次序分别存放在数组A,B中,编写程序实现两个集合的交运算(即取两个集合相同的数据元素),并把得到的交 用C语言怎么写下面这个程序?要运算步骤不是直接写输出的. 编写一个C++程序,让计算机来完成两个集合的交、并、差、笛卡儿积运算集合的运算:交运算:设A,B是两个集合,则A∩B={x|(xA)并且(xB)}并运算:设A,B是两个集合,则A∪B={x|(xA)或(xB)}差运算 试用集合A、B、C的交并补运算表示集合D(详情见补充)A=1,2,3,4,5 B=2,3 C=2,4 D=1,2,5 实数运算中的交换律、结合律,在求集合的交并集中是否适用? 用c语言编写一段程序,求两个集合的交要c语言的,直接粘过来在c++里就可以运行的那种! 用C语言写一段,可以计算任意两个输入数的和的程序 编写C语言程序,输入两个的正整数,求出它们的和、差、积、商. 集合的交并补什么时候用不是这个意思,是说在运算的过程中,在哪些地方是用交集,哪些地方用并集。 C语言课设题目,求两个集合的异或、非运算,字母为集合的元素,集合有这种运算吗? 本人碰见一道C语言难题,利用C语言实现:求任意两个集合的交集、并集、差集, pascal语言 编写一个算法实现两个集合的差运算1、编写一个算法实现两个集合的差运算,假定采用顺序存储表示,分别为S1和S2,要求在S1就地进行,即从中删除掉与S2集合中所有相同值的元素.2、编 用C语言编两个集合的交集 急!求C语言高精度加法计算的程序编程完成两个1000位以内的正整数的加法运算 求教算法,用程序写出来,什么语言都可以集合A(a b c d e f g k l m)集合B(q w e r t y u i o p)求两个集合元素的所有组合,不能重复例如(aq,qw,ae,)例如(aq,aw,ae.)上面写错了 一个C语言问题,急求!用带辅助表元的有序整数链表表示整数集合,分别编写已知两个集合求集合和(S1=S1∪S2)、集合差(S1=S1-S2)、集合交(S1=S1∩S2)的函数.运算结果在链表S1.设S1={2,3,5,6},S2=