Minggu, 24 Maret 2013

Latihan Pascal

1. uses crt;
var i : byte;
var nama : string;
begin
nama := 'ika intan rahmawati ';
textbackground(0);
clrscr;
window(15,5,65,20);
textbackground(blue);
clrscr;
textcolor(15);
i := 1;
repeat
write(copy(nama,i,1));
if i = 22 then
i := 1
else
i := i + 1
until (wherey = 16) and (wherex = 51);
readkey;
end.
 output :


















2. uses crt;
type sets : set of char;
var
a,b,irisan,union,selisih1,selisih2:sets;
lagi : char;

procedure input (var n : sets; y : byte);
var i:byte;
var ch:char;
begin
for i := 1 to 5 do
begin
gotoxy(k22+i*3,y);
ch:=upcase(readkey);
n:=n+[ch];
if i = 5 then
begin
gotoxy(22+i*3,y);writeln(ch,'}');
end
else
begin
gotoxy(22+i*3,y);
write(ch,',');
end;
end;
end;

procedure inputdata;
var i:byte;
begin
gotoxy(10,2);write('operasi himpunan');
gotoxy(10,4);write('Himpunan A = {');input(a,4);
gotoxy(10,5);write('Himpunan B = {');input(b,5);
end;

procedure cetak (n:sets;y:byte);
var i : char;
begin
gotoxy(30,y);
for i := #00 to #255 do
if n*[i] = [i] then write(' ',i,' ');
write(' } ');
end;

procedure tampilan;
begin
gotoxy(10,15);write('irisan (a,b) = {');
gotoxy(10,17);write('gabungan (a,b) = {');
gotoxy(10,19);write('selisih (a,b) = {');
gotoxy(10,21);write('selisih (b,a) = {');

cetak(irisan,15);cetak(union,17);
cetak(selisih1,19);cetak(selisih2,21);
end;

procedure proses;
begin
union := a+b;
irisan := a*b;
selisih1 := (a-b);
selisih2 := (b-a);
tampilan;
repeat
gotoxy(20,23);write('coba lagi (y/t) = ');
lagi := upcase(readkey);
until lagi in ['Y','T'];
end;

begin
while lagi <> 'T' do
begin
clrscr;
inputdata;
proses;
end;
end.
output:




Tidak ada komentar :

Posting Komentar