Pages

Monday, October 17, 2011

Menggunakan array pada Pascal (gambar grafik)


uses crt;
type
    tahun = array[1..6] of byte;
var
    data: tahun;
procedure input(var Thn:Tahun);
var i:byte;
begin
clrscr;
    gotoxy(5,1); write('Data : (Dalam Jutaan) ');
for i:= 1 to 6 do
begin
   repeat
      gotoxy(5,2+i); write('Tahun ', i, ' : ');
      gotoxy(17,2+i); clrEol;
      gotoxy(17,2+i); readln(Thn[i]);
   until (Thn[i] > 0) and (Thn[i] < 16);
  end;
end;
procedure gambar(Thn:Tahun);
var i,j : byte;
begin
  for i:= 0 to 14 do
  begin
    gotoxy(35,2+i); write(15-i:2,'│');
  end;
    gotoxy(36,17); write(0,'└');
for i:= 1 to 35 do
    write('─');
    gotoxy(39,18); write('1995  1996  1997  1998  1999  2000');
    gotoxy(41,21); write('Jumlah Penduduk Jakarta');
for i:= 1 to 6 do
for j:= 1 to Thn[i] do
begin
    gotoxy(33+i*6, 17-j); write('###');
     end;
  readkey;
end;

begin
  Input(Data);
  Gambar(Data);
end.

output yang dihasilkan :

No comments:

Post a Comment