{************************************************************************}
Unit Insiemi;
{************************************************************************}
INTERFACE
{************************************************************************}
Const MaxIns = 20;
Type Elemento = 1..MaxIns;
Insieme = Array[Elemento] Of Boolean;
Procedure AggiungiE (Var I: Insieme; e: Elemento );
Procedure TogliE (Var I: Insieme; e: Elemento );
Function AppartieneE ( I: Insieme; e: Elemento ): Boolean;
Procedure VuoToI (Var I: Insieme );
Procedure ComplemenToI (Var I: Insieme );
Procedure UnioneI (i1, i2: Insieme; Var i3: Insieme);
Procedure IntersezioneI(i1, i2: Insieme; Var i3: Insieme);
Procedure DifferenzaI (i1, i2: Insieme; Var i3: Insieme);
{
sono ancora da fare le operazioni:
Function InclusoUgI (i1, i2: Insieme): Boolean;
Function IncludeUgI (i1, i2: Insieme): Boolean;
Function UgualiI (i1, i2: Insieme): Boolean;
Function DiversiI (i1, i2: Insieme): Boolean;
}
{************************************************************************}
IMPLEMENTATION
{************************************************************************}
{********************* incapsulamenTo dei dati ... **********************}
Procedure AggiungiE(Var I: Insieme; e: Elemento);
Begin
I[e]:=True;
End;
Procedure TogliE(Var I: Insieme; e: Elemento);
Begin
I[e]:=False;
End;
Function AppartieneE(I: Insieme; e: Elemento): Boolean;
Begin
AppartieneE:=(I[e]);
End;
{************************************************************************}
Procedure VuoToI(Var I: Insieme);
Var
e: Elemento;
Begin
For e:=1 To maxIns Do
TogliE(I, e);
End;
Procedure ComplemenToI(Var I: Insieme);
Var
e: Elemento;
Begin
For e:=1 To maxIns Do
if(AppartieneE(I, e)) Then
TogliE(I, e)
else
AggiungiE(I, e);
End;
Procedure UnioneI(i1, i2: Insieme; Var i3: Insieme);
Var
e: Elemento;
Begin
VuoToI(i3);
For e:=1 To maxIns Do
if(AppartieneE(i1, e) Or AppartieneE(i2, e)) Then
AggiungiE(i3, e);
End;
Procedure IntersezioneI(i1, i2: Insieme; Var i3: Insieme);
Var
e: Elemento;
Begin
VuoToI(i3);
For e:=1 To maxIns Do
if(AppartieneE(i1, e) And AppartieneE(i2, e)) Then
AggiungiE(i3, e);
End;
Procedure DifferenzaI(i1, i2: Insieme; Var i3: Insieme);
Var
e: Elemento;
Begin
VuoToI(i3);
For e:=1 To maxIns Do
if(AppartieneE(i1, e) And Not AppartieneE(i2, e)) Then
AggiungiE(i3, e);
End;
{************************************************************************}
Begin
writeln('Unit Insiemi 20/11/2000...');
readln;
End.
{************************************************************************}