Program Input Bagian pada Pascal
Program himpunan_bagian;
Uses crt;
Type
Sets = set of char;
Var A,b,
Irisan, union,
Selisih1, Selisih2 : Sets; {Variabel Untuk Menampung Satu}
Lagi : Char;{Huruf}
Procedure Input (var N :Sets; Y:Byte);
Var I : Byte;
Ch : Char;
Begin
For I := 1 to 5 do
Begin
GotoXY (22+I*3,Y); Ch:= Upcase (Readkey);
N := N + [Ch];
If I = 5 then
Begin
GotoXY (22+I*3,Y);write(ch,’)’);
End else
Begin
GotoXY (22+I*3,Y);write(ch,’,’);
End;
End;
End;
Procedure InputData;
Var I : Byte;
Begin
GotoXY (25,1); Write(‘Operasi Himpunan’);
GotoXY (25,2); Write(‘=============’);
GotoXY (10,8); Write(‘Himpunan A : (‘); Input (A,8);
GotoXY (10,10); Write(‘Himpunan B : (‘); Input (B,10);
End;
{Procedure Untuk Cetak Isi Sets ke Layar}
Procedure Cetak (N:Sets; Y:Byte);
Var I : Char;
Begin
GotoXY (30, Y);
For I := #00 to #255 do {Utk Penjelasan baca note pada hal}
If N * [I] then write ( ‘ ’ , I , ‘ ’) ; {Berikutnya}
Write ( ‘ ) ’ ) ;
End;
Procedure Tampilkan;
Begin
GotoXY (10,15) ;Write(‘ Intersection (A,B) =(‘);;
Goto XY (10,17) :Write(‘ Union (A,B) =(‘);
Goto XY (10,19) :Write(‘ Defference (A,B) =(‘);
Goto XY (10,21) :Write(‘ Defference (B,A) =(‘);
End;
Procedure Proses;
Begin
Union := A + B ; {Sets Untuk Union}
Irisan := A * B ; {Sets Untuk Intersection}
Selisih1 := (A-B) ; {Sets Untuk Difference A-B}
Selisih2 := (B-A) ; {Sets Untuk Difference B-A}
Tampilkan;
Repeat
GotoXY(20,23); Write(‘Coba Lagi ( Y/T ) : ‘ ) ;
Lagi :=UpCase (ReadKey);
Until Lagi In [ ‘Y’,’T,’];
End;
Begin {Program Utuma}
While Lagi( ) ‘T’ do
Begin
A := [ ];
B := [ ]; {Set Dikosongkan, Agar pada saat Program}
Clrscr;
Inputdata; Proses;
Readln;
End;
End.
Tidak ada komentar:
Posting Komentar