Mathc initiation/Fichiers h : x 17c10
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c10.c |
---|
/* ---------------------------------- */
/* Save as : c10.c */
/* ---------------------------------- */
#include "x_ahfile.h"
/* ---------------------------------- */
int main(void)
{
Set A;
Set B;
Set AinterB;
Set AunionB;
int Card_A,
Card_B,
Card_AinterB,
Card_AunionB;
int i;
create_SetI(&A);
create_SetI(&B);
create_SetI(&AinterB);
create_SetI(&AunionB);
clrscrn();
for(i=1; i<=5; i++) insert_EI(&A,i);
for(i=3; i<=9; i++) insert_EI(&B,i);
p_EI(&A,'A');
printf("\n\n");
p_EI(&B,'B');
stop();
clrscrn();
printf(" A inter B :\n\n");
inter_SI(&A,&B,&AinterB);
p_EI(&AinterB,'C');
printf("\n\n");
printf(" A union B :\n\n");
union_SI(&A,&B,&AunionB);
p_EI(&AunionB,'E');
stop();
clrscrn();
Card_A = set_size(&A);
Card_B = set_size(&B);
Card_AinterB = set_size(&AinterB);
Card_AunionB = set_size(&AunionB);
printf("\n\n");
printf(" Card(A union B) = %d\n\n",Card_AunionB);
printf(" Card(A) + Card(B) - Card(A inter B) = %d\n\n",
(Card_A + Card_B - Card_AinterB) );
erase_SetI(&AunionB);
erase_SetI(&AinterB);
erase_SetI(&B);
erase_SetI(&A);
stop();
return 0;
}
Nous allons vérifier que :
Card(A union B) = Card(A) + Card(B) - Card(A inter B)
Exemple de sortie écran :
Card(A union B) = 9
Card(A) + Card(B) - Card(A inter B) = 9
Press return to continue.