1. Source Code
uses crt;
type pointer=^typedata;
Typedata = record
nilai : integer;
berikutnya : pointer;
end;
var list :pointer;
procedure mas_dep(var L : pointer; x : Integer);
var baru : pointer;
begin
new(baru);
baru^.Nilai:=x;
baru^.Berikutnya:= nil;
if L= nil then L:=baru
else
begin
baru^.berikutnya :=L;
L:= baru;
end;
end;
procedure cetak (L:pointer);
var bantu : pointer;
begin
bantu:= L;
while bantu <> nil do
begin
write (bantu^.Nilai:3);
Bantu:=bantu^.Berikutnya;
end;
end;
var bil, bil2 : integer;
JB : char;
begin
clrscr;
new(list);
list:=nil;
jb:='Y';
writeln;
writeln (' "Program Linked List" ');
writeln;
writeln ('- Masuk depan');
while upcase(Jb)='Y' do
begin
writeln;
write ('Masukkan bilangan : '); readln(bil);
mas_dep(list,bil);
write ('Lagi [Y/T] : '); readln(Jb);
end;
writeln;
cetak(list);
readln;
end.
2. Output Program
Minggu, 19 April 2015
Selasa, 14 April 2015
Tugas Praktikum Ke-6 Algoritma Pemrograman II
1. Source Code
program modul5;
program modul5;
uses crt;
var
a :
Pointer;
b : ^Byte;
c : array
[0..100] of Byte;
i : Byte;
n :
integer;
begin
clrscr;
writeln('
');
write('
Masukkan jumlah data : '); readln(n);
writeln;
writeln;
GetMem(a,
20);
b := a;
for i := 0
to n do
begin
c[i] := n -
i;
b^ := n -
i;
inc(b);
end;
b := a;
for i := 0
to n do
begin
write(' c[
', i ,' ] = ', c[i], '; ');
writeln('
a^ ke-', i ,' = ', b^);
inc(b);
end;
readln;
end.
Senin, 06 April 2015
Tugas Praktikum Ke-5 Algoritma Pemrograman II
1. Source Code
program searching;
uses crt;
label awal;
var pil:char;
lg :char;
const nmin =1;
nmax =100;
type arrint = array [nmin..nmax] of integer;
var tabint : arrint;
x,n,i,indeks,max,min,maks : integer;
function seqsearch1(xx : integer): integer;
var i : integer;
begin
i := 1;
while ((i<n) and (tabint[i] <> xx)) do
i:=i+1;
if tabint[i] = xx then
seqsearch1:=i
else
seqsearch1:=0;
end;
function maksimum (tabint: arrint; n : integer) : integer;
var i, max : integer;
begin
for i:=2 to n do
if max<tabint[i] then
max:=tabint[i];
maksimum:=max;
end;
function minimum (tabint: arrint; n : integer) : integer;
var i, min : integer;
begin
for i:=1 to n do
if min>tabint[i] then
min:=tabint[i];
minimum:=min;
end;
begin
clrscr;
writeln;
write('Masukkan Jumlah Data = '); readln(n);
writeln;
clrscr;
for i:=1 to n do
begin
write(' Data[',i,'] = '); readln(tabint[i]);
end;
writeln;
write (' Nilai yang dicari : '); readln(x);
indeks:=seqsearch1(x);
if indeks <> 0 then
write (' Nilai : ',x,' ditemukan pada indeks ke-',indeks)
else
write(' Nilai : ',x,'tidak ditemukan !');
writeln;
begin
writeln;
maks:=maksimum(tabint,n);
min:=minimum(tabint,n);
writeln;
writeln (' Nilai maksimum : ',maks);
writeln (' Nilai minimum : ',min );
readkey;
end;
end.
2. Output Program
2.1 Input Jumlah Data
2.2 Input Data
2.3 Input Nilai yang Ingin Dicari
program searching;
uses crt;
label awal;
var pil:char;
lg :char;
const nmin =1;
nmax =100;
type arrint = array [nmin..nmax] of integer;
var tabint : arrint;
x,n,i,indeks,max,min,maks : integer;
function seqsearch1(xx : integer): integer;
var i : integer;
begin
i := 1;
while ((i<n) and (tabint[i] <> xx)) do
i:=i+1;
if tabint[i] = xx then
seqsearch1:=i
else
seqsearch1:=0;
end;
function maksimum (tabint: arrint; n : integer) : integer;
var i, max : integer;
begin
for i:=2 to n do
if max<tabint[i] then
max:=tabint[i];
maksimum:=max;
end;
function minimum (tabint: arrint; n : integer) : integer;
var i, min : integer;
begin
for i:=1 to n do
if min>tabint[i] then
min:=tabint[i];
minimum:=min;
end;
begin
clrscr;
writeln;
write('Masukkan Jumlah Data = '); readln(n);
writeln;
clrscr;
for i:=1 to n do
begin
write(' Data[',i,'] = '); readln(tabint[i]);
end;
writeln;
write (' Nilai yang dicari : '); readln(x);
indeks:=seqsearch1(x);
if indeks <> 0 then
write (' Nilai : ',x,' ditemukan pada indeks ke-',indeks)
else
write(' Nilai : ',x,'tidak ditemukan !');
writeln;
begin
writeln;
maks:=maksimum(tabint,n);
min:=minimum(tabint,n);
writeln;
writeln (' Nilai maksimum : ',maks);
writeln (' Nilai minimum : ',min );
readkey;
end;
end.
2. Output Program
2.1 Input Jumlah Data
Gambar 2.1
Gambr 2.2
2.3 Input Nilai yang Ingin Dicari
Gambar 2.3
2.4 Output Hasil Data
Gambar 2.4
Langganan:
Postingan (Atom)