/*今天写代码 写着写着 超出我的认知 为什么数组定义好了长度可以随便再加元素???喵喵喵还有这坨像shit一样的代码为什么还报错还有face报错??、 */
/*
假设利用两个线性表LA,LB分别表示两个集合A,B(即线性表中的数据即为集合中的成员),现要求一个新的集合A=AUB,扩大集合A,插入新元素
*/
#include<stdio.h>
void combine(int a[],int b[]);
static int lengtha=5;
static int lengthb=4;
static int a[5]= {1,2,3,4,5};
int main()
{
//static int a[5]= {1,2,3,4,5};
int b[4]= {0,4,9,7};
//b[7]=8;
//printf("%d",b[7]);
combine(a,b);
}
void combine(int a[],int b[])//为米看着很简单,,,,,,代码啊想起来很爽写起来 辣鸡
{
int i,j;
int count=0;
for(j=0; j<lengthb; j++)
{
count=0;
for(i=0; i<5; i++)
{
if(b[j]!=a[i])
{
count++;
if(count==5)
{
// printf("差: %d\n",b[j]);
count=0;
a[lengtha++]=b[j];//insert(a,b[j]);
}
}
}
}
print(a);
}
/*void insert(int a[],int num)//往一个顺序表尾巴插入一个元素,
{
lengtha++;
a[lengtha]=num;
printf("插入:%d\n",a[lengtha]);
}*/
void print(int a[])
{
int i;
for(i=0;i<lengtha;i++)
{
printf("%d ",a[i]);
}
}
/*暂时先用顺序表实现,然后数组长度示例定值 可以改 ,,,,明天看到链表再用链表实现*/