满意答案
yuj60jj56
2018.11.22
采纳率:58% 等级:12
已帮助:9900人
|参考代码如下:
#include
#define N 20
int A[N]={0};
int B[N]={0};
int C[N]={0};
int main()
{
int a[N]={4,6,1,11,3},na=5;
int b[N]={6,7,4,1,9,12,10,15},nb=8;
int i,j,n;
//初始化
printf("A=");
for(i=0;i
A[a[i]]=1;
for(i=0;i
B[b[i]]=1;
for(i=0;i
printf("%d",A[i]);
printf("\n");
printf("B=");
for(i=0;i
printf("%d",B[i]);
printf("\n");
//求交集
printf("A与B的交集:\n");
for(i=0;i
C[i]=A[i]&&B[i];
for(i=0;i
if(C[i])printf("%d ",i);
printf("\n");
//求并集
printf("A与B的并集:\n");
for(i=0;i
C[i]=A[i]||B[i];
for(i=0;i
if(C[i])printf("%d ",i);
return 0;
}追答:
00分享举报