pascal: membuat program kotak ajaib

uses wincrt;

var

a,b,c,d,s:byte;

begin
repeat

clrscr;

writeln(‘############################################’);
writeln(‘#           Sulap Kotak Ajaib              #’);

writeln(‘############################################’);writeln;
write(‘Masukan Hasil yang diinginkan (4-250)    :’);readln(s);
if(s<4) or (s>250) then
begin
write(‘TEKAN ENTER !!!’);readln;
repeat

write(‘Kamu salah Tulis !!!!!!!!!!!!!!!!!!!!’);
until keypressed ;

halt;
end
else
randomize;
a:=s div (s div 2);
b:=s div 4;
c:=b+ (s div 3);
d:=s-(a+b+c);

gotoxy(1,8);
begin
writeln(‘ = = = = = = = = = = = = = = = = ‘);
writeln(‘=       =       =       =       =’);
writeln(‘=   ‘,a,’   =   ‘,b,’  =   ‘,c,’  =   ‘,d,’  =’);
writeln(‘=       =       =       =       =’);
writeln(‘ = = = = = = = = = = = = = = = = ‘);
writeln(‘=       =       =       =       =’);
writeln(‘=   ‘,d-3,’   =   ‘,c+3,’  =   ‘,b-1,’  =   ‘,a+1,’  =’);
writeln(‘=       =       =       =       =’);
writeln(‘ = = = = = = = = = = = = = = = = ‘);
writeln(‘=       =       =       =       =’);
writeln(‘=   ‘,b+1,’   =   ‘,a-1,’  =   ‘,d-1,’  =   ‘,c+1,’  =’);
writeln(‘=       =       =       =       =’);
writeln(‘ = = = = = = = = = = = = = = = = ‘);
writeln(‘=       =       =       =       =’);
writeln(‘=   ‘,c+2,’   =   ‘,d-2,’  =   ‘,a+2,’  =   ‘,b-2,’  =’);
writeln(‘=       =       =       =       =’);
writeln(‘ = = = = = = = = = = = = = = = = ‘);
end;
gotoxy(40,20);
write(‘By : hasan basri’:20);

readln;
until keypressed;

end.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s