Mathc initiation/Fichiers h : x 17c02
Installer et compiler ces fichiers dans votre répertoire de travail.
c02.c |
---|
/* ---------------------------------- */
/* Save as : c02.c */
/* ---------------------------------- */
#include "x_ahfile.h"
/* ---------------------------------- */
int main(void)
{
Set A,B,C,
D,E,
F,G,H;
int i;
create_SetI(&A); create_SetI(&B); create_SetI(&C);
create_SetI(&D); create_SetI(&E);
create_SetI(&F); create_SetI(&G); create_SetI(&H);
for(i=1; i<=7; i++) insert_EI(&A,i);
for(i=4; i<=10; i++) insert_EI(&B,i);
insert_EI(&C,1);insert_EI(&C,5);insert_EI(&C,9);insert_EI(&C,12);
clrscrn();
p_SetI(&A,"A");
p_SetI(&B,"B");
p_SetI(&C,"C");
printf(" D = (B inter C)\n");
inter_SI(&B,&C,&D);
p_SetI(&D,"D");
printf(" E = A union (B inter C)\n");
union_SI(&A,&D,&E);
p_SetI(&E,"E");
stop();
clrscrn();
p_SetI(&A,"A");
p_SetI(&B,"B");
p_SetI(&C,"C");
printf(" F = (A union B)\n");
union_SI(&A,&B,&F);
p_SetI(&F,"F");
printf(" G = (A union C)\n");
union_SI(&A,&C,&G);p_SetI(&G,"G");
printf(" H = (A union B) inter (A union C)\n");
inter_SI(&F,&G,&H);
p_SetI(&H,"H");
stop();
clrscrn();
printf(" A union (B inter C) = (A union B) inter (A union C)\n\n\n");
printf(" E = A union (B inter C)\n");
p_SetI(&E,"E");
printf(" H = (A union B) inter (A union C)\n");
p_SetI(&H,"H");
erase_SetI(&H);erase_SetI(&G);erase_SetI(&F);
erase_SetI(&E);erase_SetI(&D);
erase_SetI(&C);erase_SetI(&B);erase_SetI(&A);
stop();
return 0;
}
Nous allons vérifier que :
A union (B inter C) = (A union B) inter (A union C)
Exemple de sortie écran :
A union (B inter C) = (A union B) inter (A union C)
E = A union (B inter C)
E = {9,1,2,3,4,5,6,7}
H = (A union B) inter (A union C)
H = {7,6,5,4,3,2,1,9}
Press return to continue.