1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | "nomor 1"program array1D; uses crt; var i, x, cari : integer; a : array [1..100] of integer; procedure isiArray(n : integer); beginfor i := 1 to n do beginwrite('elemen array ke-', i, ' : '); readln(a[i]); end; end; procedure cetakArray(n : integer); beginfor i := 1 to n dowrite(a[i], ' '); end; procedure cariMax(n : integer); var max : integer; beginmax := a[1]; for i := 1 to n do beginif a[i] > max thenmax := a[i]; end; writeln(max); end; procedure cariMin(n : integer); var min : integer; beginmin := a[1]; for i := 1 to n do beginif a[i] < min thenmin := a[i]; end; writeln(min); end; procedure cariData(n, z : integer); var strTemu : string; beginstrTemu := ' tidak ditemukan...'; for i := 1 to n do beginif z <> a[i] then beginendelse beginstrTemu := ' ditemukan'; end; end; writeln('data ', z, strTemu); end; beginclrscr; write('banyaknya data : '); readln(x); isiArray(x); writeln; writeln; write('isi data : '); cetakArray(x); writeln; write('angka terbesar : '); cariMax(x); write('angka terkecil : '); cariMin(x); write('data yg dicari : '); readln(cari); cariData(x, cari); readlnend.""""NOMOR 2""""" program larik2; uses crt; var i, j, baris, kolom : integer; A, B, C, z : array [1..50,1..50] of integer; procedure inputMatriksA(x, y : integer); begin for i:=1 to x do begin for j:=1 to y do begin write('nilai matriks A[',i,',',j,'] = '); readln(A[i,j]); z[i,j]:=A[i,j]; end; end; end; procedure inputMatriksB(x, y : integer); begin for i:=1 to x do begin for j:=1 to y do begin write('nilai matriks B[',i,',',j,'] = '); readln(B[i,j]); z[i,j]:=B[i,j]; end; end; end; procedure cetakMatriks(x, y : integer); begin for i:=1 to x do begin for j:=1 to y do begin write(z[i,j],' '); end; writeln; end; end; procedure hitungMatriksC(x, y : integer); begin for i:=1 to x do begin for j:=1 to y do begin C[i,j] := A[i,j] + B[i,j]; z[i,j]:=C[i,j]; end; end; end; begin clrscr; write('jumlah baris = '); readln(baris); write('jumlah kolom = '); readln(kolom); writeln; inputMatriksA(baris, kolom); writeln; writeln('elemen matriks A :'); cetakMatriks(baris, kolom); writeln; inputMatriksB(baris, kolom); writeln; writeln('elemen matriks B :'); cetakMatriks(baris, kolom); writeln; writeln('matriks C :'); hitungMatriksC(baris, kolom); cetakMatriks(baris, kolom); readln end. """NOMOR 3""""program rekamDataMHS; uses crt; typedataMHS = recordNPM : string; nama : string; kodeMK : string; namaMK : string; sks : integer; nilai : char; end; var mhs : array [1..50] of dataMHS; i, jml : integer; procedure rekamData(n : integer); beginfor i := 1 to n do beginwrite('NPM : '); readln(mhs[i].NPM); write('Nama Mahasiswa : '); readln(mhs[i].nama); write('Kode MataKuliah : '); readln(mhs[i].kodeMK); write('Nama MataKuliah : '); readln(mhs[i].namaMK); write('Jumlah SKS : '); readln(mhs[i].sks); write('Nilai : '); readln(mhs[i].nilai); writeln; end; end; procedure cetakData(n : integer); beginclrscr; writeln(' NPM Nama KodeMatkul Matkul SKS Nilai'); for i := 1 to n do beginwriteln(mhs[i].NPM, mhs[i].nama : 14, mhs[i].kodeMK : 14, mhs[i].namaMK : 10, mhs[i].sks : 12, mhs[i].nilai : 12); end; end; beginclrscr; write('Banyaknya data : '); readln(jml); rekamData(jml); cetakData(jml); readlnend. |
Friday, October 30, 2009
Browse » Home »
Tugas Kampus
» Tugas Struktur Data
Tugas Struktur Data
Subscribe to:
Post Comments (Atom)
Comments :
0 comments to “Tugas Struktur Data”
Post a Comment