Senin, 19 Januari 2015
Contoh soal untuk Variabel Array Dimensi 2
Dari materi variabel array dimensi 2 yang kita pelajari sebelumnya mari kita coba untuk menyelesaikan empat (4) latihan soal di bawah ini agar bisa lebih mengerti tentang materi ini.
1. 1 0 0 0 0
2 2 0 0 0
3 3 3 0 0
4 4 4 4 0
5 5 5 5 5
2. 1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
3. 0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 1 0 0 0
1 0 0 0 0
4. * * * * *
* * * *
* * *
* *
*
Berikut Jawaban dari soal di atas:
1.
{$APPTYPE CONSOLE}
uses
SysUtils;
var
mat:array[1..10,1..10]of integer;
x,y:integer;
i:integer;
begin
writeln ('WELCOME TO munawir2706.blogspot.com');
writeln ('=================================');
writeln ('Nama : MUNAWIR');
writeln ('NIK : 114224030');
writeln ('=================================');
for x:=1 to 5 do
begin
for y:=1 to 5 do
begin
mat [x,y]:=0;
if x>=y then mat [x,y]:=x;
write (mat[x,y]:5);
end;
writeln;
end;
readln;
end.
2.
{$APPTYPE CONSOLE}
uses
SysUtils;
var
mat:array[1..10,1..10]of integer;
x,y:integer;
begin
writeln ('WELCOME TO munawir2706.blogspot.com');
writeln ('=================================');
writeln ('Nama : MUNAWIR');
writeln ('NIK : 114224030');
writeln ('=================================');
for x:=1 to 5 do
begin
for y:=1 to 5 do
begin
mat [x,y]:=0;
if x=y then mat [x,y]:=1;
write (mat[x,y]:5);
end;
writeln;
end;
readln;
end.
3.
{$APPTYPE CONSOLE}
uses
sysutils;
var
mat:array[1..10,1..10]of integer;
x,y:integer;
i:integer;
begin
writeln ('WELCOME TO munawir2706.blogspot.com');
writeln ('=================================');
writeln ('Nama : MUNAWIR');
writeln ('NIK : 114224030');
writeln ('=================================');
for x:=1 to 5 do
begin
for y:=1 to 5 do
begin
mat [x,y]:=0;
if x+y=6 then mat [x,y]:=1;
write (mat[x,y]:5);
end;
writeln;
end;
readln;
end.
4.
{$APPTYPE CONSOLE}
uses
SysUtils;
var
mat:array[1..10,1..10]of integer;
x,y:integer;
i:integer;
begin
writeln ('WELCOME TO munawir2706.blogspot.com');
writeln ('=================================');
writeln ('Nama : MUNAWIR');
writeln ('NIK : 114224030');
writeln ('=================================');
for x:=1 to 5 do
begin
for y:=1 to 5 do
begin
if x+y<=6 then write ('*':5) else write (' ');
end;
writeln;
end;
readln;
end.
Yachh.... Mungkin soal diatas sudah cukup semoga bermanfaat.
amiinnn,,,,,,
Langganan:
Posting Komentar (Atom)







0 komentar:
Posting Komentar