Program menjual_tiket;
Uses wincrt;
Type mat = array[1..10,1..10] of integer;
Function free(a: mat): Boolean;
Var
I,j : integer;
found: boolean;
Begin
Found:= true;
I:= 1;
While (found) and (i<=8) do
begin
J:=1;
While (found) and (j<=5) do
If a[I,j] =0 then
Found:=false
Else
J:= j+1;
I:= i+1;
end;
free:= found;
End;
Function cek_damping(a: mat): boolean;
Var
I,j : integer;
Found : boolean;
Begin
Found := false;
I:= 1;
While (not found) and (i<=8) do
begin
J:=1;
While (not found) and (j<5) do
If (a[I,j] <> 0) and (a[I,j+1]<>0) then
Found := true
Else
J:= j+1;
I:= i+1;
end;
Cek_damping:= found;
End;
Function kursi_pinggir(a: mat): boolean;
Var
I,j : integer;
Found : boolean;
Begin
Found := false;
j:= 1;
While (not found) and (j<=5) do
begin
I:=1;
While (not found) and (i<8) do
If a[I,j] <> 0 then
Found := true
Else
i:= i+1;
j:= j+4;
end;
kursi_pinggir:= found;
End;
Function kursi_nonton(a: mat): boolean;
Var
I,j : integer;
Found : boolean;
Begin
Found := false;
I:= 2;
While (not found) and (i<=8) do
begin
J:=1;
While (not found) and (j<5) do
If (a[I,j] <> 0) and (a[I,j+1]<>0) then
Found := true
Else
J:= j+1;
I:= i+1;
end;
kursi_nonton:= found;
End;
procedure rubah(n : integer; var a:mat);
var
i,j : integer;
begin
For i:= 1 to 8 do
For j:= 1 to 5 do
If a[I,j] = n then
If a[I,j] = n then
A[I,j] :=0;
end;
Var
y: string;
a: mat;
i,j,n: integer;
hasil, hasil1, hasil2, hasil3 : boolean;
Begin
For i:= 1 to 8 do
For j:= 1 to 5 do
A[I,j] := ((i*5)-5+j);
For i:= 1 to 8 do
begin
For j:= 1 to 5 do
Write(a[I,j], ' ');
Writeln;
End;
repeat
Writeln('masukkan no tempat duduk yang anda inginkan');
Readln(n);
clrscr;
hasil := free(a);
writeln('bangku yang anda pesan masih dalam keadaan ', hasil);
writeln;
rubah(n,a);
For i:= 1 to 8 do
begin
For j:= 1 to 5 do
Write(a[I,j], ' ');
Writeln;
End;
writeln('apakah masih ada yang ingin memesan tiket pesawat???? (Y/N) ');
readln(y);
until y = 'n';
hasil1:= cek_damping(a);
writeln(hasil1);
hasil2:= kursi_pinggir(a);
writeln(hasil2);
hasil3:= kursi_nonton(a);
writeln(hasil3);
End.
No comments:
Post a Comment