Mathc initiation/Fichiers h : x 17c12

Un livre de Wikilivres.


Sommaire


Installer et compiler ces fichiers dans votre répertoire de travail.

c12.c
/* ---------------------------------- */
/*  Save as :   c12.c                 */
/* ---------------------------------- */
#include "x_ahfile.h"
/* ---------------------------------- */
int main(void)
{
Set  A,B,S,
     AunionB,C_AunionB,
     C_A,C_B,C_AinterC_B;

int  i;
 
  create_SetI(&A);
  create_SetI(&B);
  create_SetI(&S);
  create_SetI(&AunionB);
  create_SetI(&C_AunionB);
  create_SetI(&C_A);
  create_SetI(&C_B);
  create_SetI(&C_AinterC_B);
  
  for(i=5; i<=10; i++) insert_EI(&A,i);
  for(i=7; i<=13; i++) insert_EI(&B,i);  
  for(i=1; i<=15; i++) insert_EI(&S,i);  

  clrscrn();
    
  p_SetI(&A,"A");
  p_SetI(&B,"B");
  p_SetI(&S,"S");
  
  printf("\n (A union B)^c\n");
  union_SI(&A,&B,&AunionB);
  compl_SI(&AunionB,&S,&C_AunionB);
  p_SetI(&C_AunionB,"(A union B)^c");
    
  printf("\n A^c inter B^c\n");
  compl_SI(&A,&S,&C_A);  
  compl_SI(&B,&S,&C_B);  
  inter_SI(&C_A,&C_B,&C_AinterC_B);
  p_SetI(&C_AinterC_B,"A^c inter B^c");  
   
  if(equal_SI(&C_AunionB,&C_AinterC_B)) 
     printf("\n (A union B)^c  = A^c inter B^c\n\n");
  else                                  
     printf("\n (A union B)^c != A^c inter B^c\n\n");  
  
  erase_SetI(&A);
  erase_SetI(&B);
  erase_SetI(&S);
  erase_SetI(&AunionB);
  erase_SetI(&C_AunionB);
  erase_SetI(&C_A);
  erase_SetI(&C_B);
  erase_SetI(&C_AinterC_B);

  stop();

  return 0;
}


Nous allons vérifier que :

 (A union B)^c  = A^c inter B^c


Exemple de sortie écran :

 A = {10,9,8,7,6,5}

 B = {13,12,11,10,9,8,7}

 S = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}


 (A union B)^c
 (A union B)^c = {1,2,3,4,14,15}


 A^c inter B^c
 A^c inter B^c = {15,14,4,3,2,1}


 (A union B)^c  = A^c inter B^c

 Press return to continue.