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