Mathc initiation/Fichiers h : x 17c07
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c07.c |
---|
/* ---------------------------------- */
/* Save as : c07.c */
/* ---------------------------------- */
#include "x_ahfile.h"
/* ---------------------------------- */
int main(void)
{
Set A,B,C;
int i;
create_SetI(&A); create_SetI(&B); create_SetI(&C);
clrscrn();
for(i=1; i<=5; i++) insert_EI(&A,i);
for(i=1; i<=9; i++) insert_EI(&B,i);
p_SetI(&A,"A");
p_SetI(&B,"B");
if(subset_SI(&A,&B)) printf(" A is include in B\n\n\n\n");
else printf(" A is not include in B\n\n\n\n");
printf(" if A inter B = A => A include into B\n\n");
printf(" C = A inter B\n\n");
inter_SI(&A,&B,&C);
p_SetI(&C,"C");
erase_SetI(&B); erase_SetI(&A); erase_SetI(&C);
stop();
clrscrn();
for(i=1; i<=5; i++) insert_EI(&A,i);
for(i=3; i<=9; i++) insert_EI(&B,i);
p_SetI(&A,"A");
p_SetI(&B,"B");
if(subset_SI(&A,&B)) printf(" A is include in B\n\n\n\n");
else printf(" A is not include in B\n\n\n\n");
printf(" if A inter B = A => A include into B\n\n");
printf(" C = A inter B\n\n");
inter_SI(&A,&B,&C);
p_SetI(&C,"C");
erase_SetI(&C); erase_SetI(&B); erase_SetI(&A);
stop();
return 0;
}
Nous allons vérifier si un ensemble A est bien un sous ensemble de B.
Exemple de sortie écran :
A = {5,4,3,2,1}
B = {9,8,7,6,5,4,3,2,1}
A is include in B
if A inter B = A => A include into B
C = A inter B
C = {1,2,3,4,5}