Un tip de date mulţime (set) se defineşte în raport cu un tip de bază care trebuie să fie ordinal.
Problema:
Creați un program care arata reuniunea, intersecția și diferența a două mulțimi.
Uses CRT;
Type Multime=Set of Byte;
Var A,B,R,I,D:Multime; N,M,K,X:Byte;
Begin ClrScr;
Write ('elementele:'); Readln (X);
A:=A+[X] end;
Write ('Numarul de elemente:'); Readln(M); B:=[ ];
For K:=1 To N Do Begin
Write('elementele:'); Readln (X);
B:=B+[X] end;
R:=A+B; I:=A*B; D:=A-B;
Writeln ('Reuniunea');
For K:=0 To 255 Do
If K in R then Write (L,' '); Writeln;
Writeln('Intersecția;);
Fork K:=0 To 255 Do
If K in I then Write (K,' '); Writeln;
Writeln('Diferența');
For K:=0 To 255 Do
If K in D then Write (K,' '); Readkey end.
Problema:
Creați un program care arata reuniunea, intersecția și diferența a două mulțimi.
Uses CRT;
Type Multime=Set of Byte;
Var A,B,R,I,D:Multime; N,M,K,X:Byte;
Begin ClrScr;
Write ('elementele:'); Readln (X);
A:=A+[X] end;
Write ('Numarul de elemente:'); Readln(M); B:=[ ];
For K:=1 To N Do Begin
Write('elementele:'); Readln (X);
B:=B+[X] end;
R:=A+B; I:=A*B; D:=A-B;
Writeln ('Reuniunea');
For K:=0 To 255 Do
If K in R then Write (L,' '); Writeln;
Writeln('Intersecția;);
Fork K:=0 To 255 Do
If K in I then Write (K,' '); Writeln;
Writeln('Diferența');
For K:=0 To 255 Do
If K in D then Write (K,' '); Readkey end.
Comentarii
Trimiteți un comentariu