Tentang Mekatronika

Selasa, 05 Februari 2008

LATIHAN PASCAL, MENGURUTKAN ANGKA

PROGRAM MENGURUTKAN_ANGKA;

USES CRT;

VAR PIL:SHORTINT;

Z,A,B,C,D,E,F:LONGINT;

CON,PLH:STRING[1];

BEGIN

REPEAT

CLRSCR;TEXTCOLOR(GREEN);

GOTOXY(27,2);WRITELN('PROGRAM MENGURUTKAN ANGKA');

GOTOXY(29,3);WRITELN('MADE BY AJIE JAMALUDIN');

GOTOXY(19,4);WRITELN('TEKNIK OTOMASI MANUFAKTUR DAN MEKATRONIKA');

GOTOXY(22,5);WRITELN('POLITEKNIK MANUFAKTUR NEGERI BANDUNG');

WRITELN('================================================================================');

TEXTCOLOR(18);GOTOXY(29,23);WRITELN('FULL SCREEN : ALT+ENTER');

TEXTCOLOR(GREEN);

GOTOXY(18,9); WRITELN('MASUKKAN ANGKA PERTAMA : ');GOTOXY(43,9);READLN(A);

GOTOXY(18,10);WRITELN('MASUKKAN ANGKA KEDUA : ');GOTOXY(43,10);READLN(B);

GOTOXY(18,11);WRITELN('MASUKKAN ANGKA KETIGA : ');GOTOXY(43,11);READLN(C);

GOTOXY(18,12);WRITELN('MASUKKAN ANGKA KEEMPAT : ');GOTOXY(43,12);READLN(D);

GOTOXY(18,13);WRITELN('MASUKKAN ANGKA KELIMA : ');GOTOXY(43,13);READLN(E);

BEGIN

IF A>B THEN

BEGIN

Z:=A;A:=B;B:=Z;

END;

IF A>C THEN

BEGIN

Z:=A;A:=C;C:=Z;

END;

IF A>D THEN

BEGIN

Z:=A;A:=D;D:=Z;

END;

IF A>E THEN

BEGIN

Z:=A;A:=E;E:=Z;

END;

IF B>C THEN

BEGIN

Z:=B;B:=C;C:=Z;

END;

IF B>D THEN

BEGIN

Z:=B;B:=D;D:=Z;

END;

IF B>E THEN

BEGIN

Z:=B;B:=E;E:=Z;

END;

IF C>D THEN

BEGIN

Z:=C;C:=D;D:=Z;

END;

IF C>E THEN

BEGIN

Z:=C;C:=E;E:=Z;

END;

IF D>E THEN

BEGIN

Z:=D;D:=E;E:=Z;

END;

END;

GOTOXY(18,15);WRITELN('KETIK 1 UNTUK URUTAN DARI KECIL KE BESAR');

GOTOXY(18,16);WRITELN('KETIK 2 UNTUK URUTAN DARI BESAR KE KECIL');

GOTOXY(36,17);WRITELN('( )');GOTOXY(38,17);READLN(PIL);

BEGIN

GOTOXY(18,15);CLREOL;GOTOXY(18,16);CLREOL;

GOTOXY(32,17);WRITELN('URUTANNYA ADALAH');

CASE PIL OF

1:WRITELN(A:10,B:10,C:10,D:10,E:10);

2:WRITELN(E:10,D:10,C:10,B:10,A:10);

END;

GOTOXY(41,24);READLN;

CLRSCR; GOTOXY(30,17);WRITELN('MENGULANG ? (y,t)');GOTOXY(48,17); READLN(CON);

END;

UNTIL (CON='t') or (CON='T');

END.

Tidak ada komentar:

Posting Komentar