RSS

pascal lagi

08 Oct

program praktikum;

uses crt;
const Nmaks = 100;

type

titik=record
x:array [1..Nmaks] of real;
y:array [1..Nmaks] of real;
end;
type

tabel=array [1..nMaks] of integer;

var
x       :tabel;
y       :tabel;
n,i    :integer;
a       :real;
p1,p2,p3 :titik;

procedure isiTitik (var a,b:tabel; n:integer);
var
i:integer;
begin
writeln(‘—Masukkan nilai titik—‘);
for i:=1 to n do
begin
write(‘titik x: ‘);readln(a[i]);
write(‘titik y: ‘);readln(b[i]);
end;
end;

function minxy(a,b:tabel;n:integer):integer;
var
i, minx, miny:integer;
begin
minx := 9999;
miny := 9999;
for i := 1 to n do
begin
if b[i] < miny then
miny:= b[i];
if a[i] < minx then
minx := a[i];
end;
writeln (‘nilai x minimum : ‘, minx);
writeln (‘nilai y minimum : ‘, miny);
end;

function maxxy(a,b:tabel;n:integer):integer;
var
i,maxx, maxy:integer;
begin
maxx := 0;
maxy := 0;
for i := 1 to n do
begin
if x[i] > maxx then
maxx := x[i];
if y[i] > maxy then
maxy := y[i];
end;
writeln (‘nilai x maximum : ‘, maxx);
writeln (‘nilai y maximum : ‘, maxy);
end;
procedure pindahTitik(a,b:tabel);
var

i,j :integer;
temp:integer;
temp1:integer;
begin
writeln(‘—–PINDAH TITIK—–‘);
write(‘index titik 1 :’);readln(i);
write(‘index titik 2 :’);readln(j);
temp:=a[i];
temp1:=b[i];
a[i]:=a[j];
b[i]:=b[j];
a[j]:=temp;
b[j]:=temp1;
writeln(‘Hasil titik setelah penukaran’);
writeln(a[i],’,’,b[i]);
writeln(a[j],’,’,b[j]);
writeln;
end;

function ambilTitik(a,b:tabel;index:integer):integer;
var

i,j:integer;
begin
writeln(‘——-AMBIL TITIK——-‘);
write(‘index titik yang diambil :’); readln(index);

j:=a[index];
i:=b[index];
writeln(j,’,’,i);
end;

procedure cetakTitik(var a,b:tabel; n:integer);
var
i:integer;

begin
writeln(‘—SEMUA TITIK YANG DIINPUTKAN–‘);
for i:=1 to n do
writeln(a[i],’,’,b[i]);
end;

function titikTengah(a,b:tabel):real;
var
i,j:integer;
c,d:real;
begin
writeln(‘——CARI TITIK TENGAH—–‘);
writeln;
write(‘masukkan lokasi titik 1: ‘);readln(i);
writeln(‘titik 1= ‘,a[i],’,’,b[i]);
write(‘masukkan lokasi titik 2: ‘);readln(j);
writeln(‘titik 2=’,a[j],’,’,b[j]);
writeln;
c:=(a[i]+a[j])/2;
d:=(b[i]+b[j])/ 2;
writeln(‘Titik tengahnya yaitu: ‘, c:0:2,’,’,d:0:2);
end;

procedure translasi(a,b:tabel);
var
i,j:integer;
begin
writeln(‘——-TRANSLASI——‘);
write(‘masukkan posisi titik yang ingin digeser: ‘);readln(i);
writeln(‘Titik yang ditemukan’);
writeln(a[i],’,’,b[i]);
write(‘masukkan index pergeseran: ‘);readln(j);
a[i]:=a[i]+j;
b[i]:=b[i]+j;
writeln(‘hasil translasi: ‘,a[i],’,’,b[i]);
end;

procedure dilatasi(a,b:tabel);
var
i,j:integer;
begin
writeln(‘——–DILATASI——-‘);
write(‘masukkan posisi titik :’);readln(j);
writeln(‘Titik yang ditemukan’);
writeln(a[j],’,’,b[j]);
write(‘masukkan index perbesaran: ‘);readln(i);
a[j]:=a[j]*i;
b[j]:=b[j]*i;
writeln(‘hasil dilatasi: ‘,a[j],’,’,b[j]);
end;

begin
clrscr();
write (‘Masukkan banyak index: ‘); readln(n);
writeln;
write ();
isiTitik(x,y,n);
writeln;
cetakTitik(x,y,n);
writeln;
minxy(x,y,n);
writeln;
maxxy(x,y,n);
writeln;
titikTengah(x,y);
writeln;
ambilTitik(x,y,n);
writeln;
pindahTitik(x,y);
writeln;
translasi(x,y);
writeln;
dilatasi(x,y);
readln;
end.

 
Leave a comment

Posted by on October 8, 2009 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: