• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content




tugas mata kuliah algoritma & struktur data

tugas mata kuliah algoritma & struktur data



Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds


Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Algoritma Algoritma Document Transcript

    • Nama : Venta Adrian AhnafNIM : 10508447Kelas : MI-9 1. Program Mencari Nilai Minimum uses crt; type arrint = array[1..10] of integer; var mins :integer; tabint:arrint; nn : integer; i : integer; function minimum(tabint : arrint ; n : integer):integer; var i:byte; min:byte; begin min:=tabin2[1]; for i:=2 to n do if min > tabin2[i] then min := tabint[i]; minimum :=min; end; begin clrscr; write(Jumlah elemen= );readln(nn); for i := 1 to nn do begin write(elemen ke-,i,=);readln(tabint2[i]); end; mins := minimum (tabint,nn); writeln(Nilai Minimum = , mins); readln; end. OUTPUT:
    • 2. Program Mencari indeks dimana Nilai minimum disimpan OUTPUTuses crt;type OUTPUT : arrint = array[1..10] of integer;var imins :integer; tabint:arrint; nn,i :integer;function iminimum(tabint : arrint; n:integer):integer;vari,imin :integer;. beginimin := 1;for i:=2 to n do if tabint2[imin] > tabint2 [i] then imin :=i; iminimum := imin;end;beginclrscr;write(Jumlah elemen= );readln(nn);for i := 1 to nn dobeginwrite(elemen ke-,i,=);readln(tabint2[i]);end;imins := iminimum (tabint2,nn);writeln(Indeks Minimum = ,imins);readln;end.
    • 3. Program Pengurutan Ascending (terurut membesar)uses crt; for i:=min to max doconst tabfrek[i]:=0; nmax=100; for i:=1 to n dotype tabfrek[tabint[i]]:=tabfrek[tabint[i]]+1; arrint=array[0..nmax] of integer;var j:=0; tabint:arrint; for i:=min to max do n:integer; begin if tabfrek[i]<>0 thenprocedure isidata; beginvar for k:=1 to tabfrek[i]do i:integer; beginbegin inc(j); clrscr; tabint[j]:=i; randomize; end; for i:=1 to n do end; tabint[i]:=random(nmax); end; end; end; beginprocedure tulisdata; clrscr;var write(jumlah elemen=);readln(n); i:integer; isidata;begin writeln(data sebelum terurut); for i:=1 to n do tulisdata; write(tabint[i], ); hitungurut;end; writeln; writeln;procedure hitungurut; writeln(data terurut membesar);var tulisdata; max,min,i,j,k:integer; readln; tabfrek :arrint; end.begin min:=tabint[1]; for i:=1 to n do if tabint[i]<min then OUTPUT : min:=tabint[i]; max:=tabint[1]; for i:=1 to n do if tabint[i]>max then max:=tabint[i];
    • 4. Nilai top score Bolauses crt; gotoxy(5,j);write(name[i]);type gotoxy(25,j);write(goal[i]); nama = array[1..10] of string; j:=j+1; gol = array[1..10] of integer; end;var end; i,n,maks,imaks,j :integer; name:nama; begin goal:gol; clrscr;procedure input; input;begin view; write(Jumlah Data =);readln(n); writeln; for i:=1 to n do writeln(Top Skor sampai saat ini); begin imaks := imaksimum (goal,n); writeln(Data ke-,i,=); writeln(Nama: ,name[imaks]); write(Nama = );readln(name[i]); maks := maksimum (goal,n); write(Jumlah Gol = );readln(goal[i]); writeln(Jumlah Gol: ,maks); end;end; readln;function maksimum(bsr : gol ; nn : integer):integer; end.var i:byte; max:byte;begin OUTPUT: max:=bsr[1];for i:=2 to nn do if max < bsr[i] then max := bsr[i]; maksimum :=max;end;function imaksimum(bsr : gol ; nn : integer):integer;var i:byte; imax:byte;begin max:=1;for i:=2 to nn do if bsr[imax] < bsr[i] then imax := i; imaksimum := imax;end;procedure view;begin clrscr; writeln(Top Skor Liga Tarkam 2009-2010); writeln(No Nama Jumlah Gol); writeln(==========================); j:=4; for i:=1 to n do begin gotoxy(1,j);write(i);