2.25-将顺序表A,B的交集用C存储

#define max 10
typedef struct
{
    int elem[max];
    int length;
}Seqlist;
void Same(Seqlist&A,Seqlist&B,Seqlist&C)
{
    int i,j,k=0,lena=A.length,lenb=B.length;
    for(i=0;i<lena;i++)
    {
        for(j=0;j<lenb;j++)
        {
            if(A.elem[i]==B.elem[j])
            {
                C.elem[k++]=A.elem[i];
                break;
            }
        }
    }
    C.length=k;
}


你可能感兴趣的:(2.25-将顺序表A,B的交集用C存储)