Mathc initiation/Fichiers h : x 17a3


Sommaire


Installer ce fichier dans votre répertoire de travail.

xopset.h
utilitaire
/* ------------------------------------ */
/*  Save as :   xopset.h                */
/* ------------------------------------ */
void union_SI(
Set *A,
Set *B,
Set *C)
{
Element *element_A;
Element *element_B;
int           size;
int           data;

  size = set_size(A); 
  if( size )
  {
   element_A = set_head(A);
   while(size>=1)
     {
      data = element_data(element_A);
      insert_EI(C,data);
      element_A=element_next(element_A);
      size--;
     }
  }

  size = set_size(B);
  if( size )
  {
   element_B = set_head(B);
   while(size>=1)
     {
      data = element_data(element_B);
      insert_EI(C,data);
      element_B=element_next(element_B);
      size--;
     }
  }
}
/* ------------------------------------ */
void inter_SI(
Set *A,
Set *B,
Set *C)
{
Element *element_A;
int          sizeA;
int           data;

  sizeA = set_size(A);
  if( sizeA || set_size(B))
    {
     element_A = set_head(A);
     while(sizeA>=1)
       {
        data = element_data(element_A);
        if(member_EI(B,data)) insert_EI(C,data);
        element_A=element_next(element_A);
        sizeA--;
       }
    }
}
/* ------------------------------------ */
void mns_SI(
Set *A,
Set *B,
Set *C)
{
Element *element_A;
int          sizeA;
int           data;

  sizeA = set_size(A);
  if( sizeA )
    {
     element_A = set_head(A);
     while(sizeA>=1)
       {
        data = element_data(element_A);
        if(!(member_EI(B,data))) insert_EI(C,data);
        element_A=element_next(element_A);
        sizeA--;
       }
    }
}
/* ------------------------------------ */
void delta_SI(
Set *A,
Set *B,
Set *C)
{
Element *element_A;
Element *element_B;
int           size;
int           data;

  size = set_size(A);
  if( size )
    {
     element_A = set_head(A);
     while(size>=1)
       {
        data = element_data(element_A);
        if(!(member_EI(B,data))) insert_EI(C,data);
        element_A=element_next(element_A);
        size--;
       }
    }

  size = set_size(B);
  if( size )
    {
     element_B = set_head(B);
     while(size>=1)
       {
        data = element_data(element_B);
        if(!(member_EI(A,data))) insert_EI(C,data);
        element_B=element_next(element_B);
        size--;
       }
    }
}
/* ------------------------------------ */
int subset_SI(
Set *A,
Set *B)
{
Element *element_A;
int          sizeA;
int           data;

  if( set_size(A)>set_size(B) )return(0);

  sizeA = set_size(A);
  if( sizeA )
    {
     element_A=set_head(A);
     while(sizeA>=1)
       {
        data = element_data(element_A);
        if(!(member_EI(B,data))) return(0);
        element_A=element_next(element_A);
        sizeA--;
       }
    }
 return(1);
}
/* ------------------------------------ */
int propersubset_SI(
Set *A,
Set *B)
{
Element *element_A;
int          sizeA;
int           data;

  if( set_size(A)>=set_size(B) )return(0);

  sizeA = set_size(A);
  if( sizeA )
    {
     element_A=set_head(A);
     while(sizeA>=1)
       {
        data = element_data(element_A);
        if(!(member_EI(B,data))) return(0);
        element_A=element_next(element_A);
        sizeA--;
       }
    }
 return(1);
}
/* ------------------------------------ */
int equal_SI(
Set *A,
Set *B)
{
 if( set_size(A)!=set_size(B) )return(0);

 return(subset_SI(A,B));
}
/* ------------------------------------ */
void compl_SI(
Set *A,
Set *B,
Set *C)
{
Element *element_B;
int           size;
int           data;

   if(subset_SI(A,B))
     {
      size = set_size(B);
      element_B = set_head(B);
      while(size>=1)
        {
         data = element_data(element_B);
         if(!(member_EI(A,data))) insert_EI(C,data);
         element_B=element_next(element_B);
         size--;
        }
      }
   else printf(" The fisrt set is not a subset of the second set\n\n");
}


Je suppose que vous connaissez les opérateurs mathématiques de ce fichier.