Data Structure Practice

A week ago i’ve started data structure practice in trunojoyo laboratory. Exactly, it is in programming laboratory. When the lecture assistant started it, i asked him about what kind of programming language that will be used by us. He said to me that in this data structure practice, we’ll use PASCAL programming language. Actually, I’ m so dissapointed for this. But, He explain to me that it is the decision of the main Coordinator of Data structure practice, so that we can’t change it. I’ve learned about C programming language for a long time. but now it is not used again. Huch….But, i’m not gonna be breaking down only because of this. i’ll try to do the as best as i can do.
Any way, The 1st modul is about ARRAY .so , i don’t worry about that. Here is the program that must be submitted
1. Average of array


program rata_rata;
uses wincrt;
var
a,b,c:integer;
d:real;
data:array[1..100]of integer;
begin
write('Masukkan jumlah data total = ');read(a);

for b:=1 to a do
begin
write('INDEX[',b,']=');read(data[b]);
c:=c+data[b];
end;

d:=c/b;
writeln('hasil total = ',c);
writeln('hasil rata- rata =',d:2:2);
end.

2. Palindrom
3. Statistic


PROGRAM SERIBU;
USES WINCRT;
TYPE DATA=ARRAY[1..100,1..100] OF INTEGER;
VAR
PRIA,WANITA:DATA;
A,B,C,D,E,F,h,maxa,maxb,i,j,k,l:integer;
hari:array[1..7]of string;
bulan:array[1..12]of string;

PROCEDURE INPUT(A,B:BYTE);
BEGIN
d:=0;
h:=0;
hari[1]:='Sen';
hari[2]:='Sel';
hari[3]:='Rab';
hari[4]:='Kam';
hari[5]:='Jum';
hari[6]:='Sab';
hari[7]:='Min';
bulan[1]:='jan';
bulan[2]:='feb';
bulan[3]:='mar';
bulan[4]:='apr';
bulan[5]:='mei';
bulan[6]:='jun';
bulan[7]:='jul';
bulan[8]:='agu';
bulan[9]:='sep';
bulan[10]:='okt';
bulan[11]:='nov';
bulan[12]:='des';
write('     ');
for e:=1 to 12 do
begin
write(bulan[e]:6);
end;
writeln;
FOR E:=1 TO b DO
BEGIN
write(hari[e]);
FOR F:=1 TO a DO
BEGIN
c:=random(15);
write(c:6);
pria[e,f]:=c;
d:=d+pria[e,f];
END;
writeln;
END;
write('Jumlah Laki - Laki = ',d);

writeln;
writeln;
write('     ');
for e:=1 to 12 do
begin
write(bulan[e]:6);
end;
writeln;
FOR E:=1 TO b DO
BEGIN
write(hari[e]);
FOR F:=1 TO a DO
BEGIN
c:=random(14);
write(c:6);
wanita[e,f]:=c;
h:=h+wanita[e,f];
END;
writeln;
END;
writeln;
writeln('Jumlah perempuan = ',h);

{proses}

maxa:=pria[1,1];
FOR E:=1 TO b DO
BEGIN
FOR F:=1 TO a DO
BEGIN
if pria[e,f]>maxa then
begin
maxa:=pria[e,f];
i:=e;
j:=f;
end;
END;
END;

maxb:=wanita[1,1];
FOR E:=1 TO b DO
BEGIN
FOR F:=1 TO a DO
BEGIN
if wanita[e,f]>maxb then
begin
maxb:=wanita[e,f];
k:=e;
l:=f;
end;
END;
END;

writeln;
if maxa>maxb then
writeln('Terbanyak adalah Laki- Laki di bulan ',bulan[j],' hari ',hari[i],' ',maxa,' orang')
else if maxb>maxa then
writeln('Terbanyak adalah Laki- Laki di bulan ',bulan[l],' hari ',hari[k],' ',maxb,' orang')
else
writeln('SAMA');

END;

BEGIN
a:=12;
b:=7;
randomize;
input(a,b);
END.

4. set

Fortunately i got task number 1 and 3. So, i did’n need to work harder to finish it all.
I really hope in the next practice which is related to programming can use C. Amin…

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: