Mathc initiation/Fichiers h : x 17b08
Installer et compiler ces fichiers dans votre répertoire de travail.
b08.c |
---|
/* ---------------------------------- */
/* Save as : b08.c */
/* ---------------------------------- */
#include "x_ahfile.h"
/* ---------------------------------- */
int main(void)
{
Set A;
Set B;
int i;
create_SetI(&A);
create_SetI(&B);
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");
else printf(" A is not include in B\n\n");
erase_SetI(&B);
erase_SetI(&A);
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");
else printf(" A is not include in B\n\n");
erase_SetI(&B);
erase_SetI(&A);
stop();
return 0;
}
Cette fonction permet de déterminer si un ensemble A est inclus dans 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
Press return to continue.