Program Urut Ascending Dan Descending

  • Uploaded by: Lucky Apocalypse
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Program Urut Ascending Dan Descending as PDF for free.

More details

  • Words: 452
  • Pages: 3
By Lukman Wahyudi 1 Program Urut Ascending Dan Descending

PROGRAM URUT ASCENDING DAN DESCENDING Ini adalah sebuah program urut dengan masukan 4 nama buah, yang kemudian akan di keluarkan secara berurutan berdasarkan abjad. Pengurutan dalam program ini dapat kita lakukan secara Ascending ataupun Descending. Berikut adalah Source Code dari program urut beserta gambarnya. Source Code Program Urut;

end;

uses wincrt;

end;

label 1,2;

procedure Descending;

var x : array[0..3] of string;

var

y : array[0..3] of string;

i, j, tempatnya_min : integer;

pilih : char;

min, temp : string;

i : integer;

begin for j := 0 to 3 do

procedure Ascending;

begin

var

min := x[j];

i, j, tempatnya_max : integer;

for i := j to 3 do

max, temp : string;

begin

begin

if (x[i] >= min) then

for j := 0 to 3 do

begin

begin

min := x[i];

max := x[j];

tempatnya_min := i;

for i := j to 3 do

end;

begin

end;

if (x[i] <= max) then

temp := x[j];

begin

x[j] := x[tempatnya_min];

max := x[i];

x[tempatnya_min] := temp;

tempatnya_max := i; end; end; temp := x[j]; x[j] := x[tempatnya_max];

end; clrscr; gotoXY(5,17); writeln('Hasil data yang telah di urut secara Descending'); for i := 0 to 3 do begin

x[tempatnya_max] := temp;

gotoxy(25,19+i); write(x[i]);

end;

end;

clrscr; gotoXY(5,17); writeln('Hasil data yang telah di urut secara Ascending'); for i := 0 to 3 do begin gotoxy(25,19+i); write(x[i]);

end; begin { Program Utama } 1 : gotoxy(5,1); writeln('Masukkan 4 nama buah'); write('Masukkan nama buah 1 : '); readln(x[0]);

By Lukman Wahyudi

By Lukman Wahyudi 2 Program Urut Ascending Dan Descending write('Masukkan nama buah 2 : '); readln(x[1]);

gotoXY( 5,12); write('| Pilih :

write('Masukkan nama buah 3 : '); readln(x[2]);

gotoXY( 5,13); write('|_______________|');

write('Masukkan nama buah 4 : '); readln(x[3]);

gotoXY(17,12); pilih := readkey;

clrscr;

if pilih = '1' then

for i := 0 to 3 do

|');

Ascending

begin y[i] := x[i];

else if pilih = '2' then

end;

Descending

repeat 2 : gotoxy(15,15); clrEoL;

else if pilih = '3' then

gotoXY(34,6); writeln('Urutan Awal Data');

begin

for i := 0 to 3 do

clrscr;

begin

goto 1;

gotoXY(41,i+7); write(y[i]);

end

end;

else

gotoXY( 5,2); write('|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|'); gotoXY( 5,3); write('|

Menu :

begin

|');

gotoXY( 5,4); write('|_______________|'); gotoXY( 5,5); write('|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|');

clrscr; gotoxy(15,15); write('Maaf anda hanya dapat memilih dari no 0-3');

gotoXY( 5,6); write('| 1. Ascending |');

readkey; goto 2;

gotoXY( 5,7); write('| 2. Descending |');

clrscr;

gotoXY( 5,8); write('| 3. New gotoXY( 5,9); write('| 0. Quit

end;

|'); |');

gotoXY( 5,10); write('|_______________|');

until pilih = '0'; end.

gotoXY( 5,11); write('|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|');

By Lukman Wahyudi

By Lukman Wahyudi 3 Program Urut Ascending Dan Descending

Gambar Runing Program

Gambar Masukan Data

Gambar Data Urut Ascending

Gambar Data Urut Descending

By Lukman Wahyudi

Related Documents

Urut
June 2020 18
Ascending Order.docx
December 2019 14
Descending Tracts
July 2020 7
Descending Mt. Tai.
May 2020 3

More Documents from ""