Rabu, 10 Oktober 2012

sod


PROGRAM SHORT_DATAMHS;
uses crt;
const
garis='-----------------------------';
var
Nama,NPM,kelas     :array [1..15]of dataMHS;
n,i,bar,x,z,pil: Integer;
min,temp:string;
label Menu;
label exit;
begin
clrscr;
write('mau isi berapa data :');
readln(n);
for i:= 1 to n do
begin
clrscr;
GOTOXY(30,4);WRITE('DATA KE-',i:2);
GOTOXY(10,7);WRITE('NPM  :') ; READLN(NPM[i]);
GOTOXY(10,8);WRITE('NAMA :'); READLN(NAMA[i]);
GOTOXY(10,9);WRITE('KELAS:'); READLN(KELAS[i]);
END;
MENU:
CLRSCR;
WRITELN('MASUKAN PILIHAN ANDA :');
WRITELN('1.URUTKAN BERDASARKAN KELAS');
WRITELN('2.URUTKAN BERDASARKAN NAMA');
WRITELN('3.EXIT');
WRITE ('PILIH PILIHAN ANDA :');READLN(PIL);
CASE PIL OF
1:FOR KELOMPOK := 1 TO N DO
BEGIN
MIN:=KELAS[X];
FOR I :=KELOMPOK TO N DO
BEGIN
IF (KELAS [i] <= MIN) THEN
BEGIN
MIN:=KELAS[I];
TEMPATNYA_MIN:=i;
END;
TEMP := KELAS[X];
KELAS[X]:=KELAS[Z];
KELAS[Z]:=TEMP;
TEMP:= NAMA[X];
NAMA[X]:=NAMA[Z];
NAMA[Z]:=TEMP;
TEMP :=NPM[X];
NPM[X]:= NPM[Z];
NPM[Z]:= TEMP;
END;
END;
2:FOR KELOMPOK := 1 TO N DO
BEGIN
MIN := NAMA [X];
FOR i:= KELOMPOK TO N DO
BEGIN
IF (NAMA[i] <=MIN)THEN
BEGIN
MIN:= NAMA[i];
TEMPATNYA_MIN:=i;
END;
END;
TEMP:=KELAS[X];
KELAS[X] :=KELAS[Z];
KELAS[Z]:=TEMP;
TEMP:=NAMA[X];
NAMA[X]:=NAMA[Z];
NAMA[Z]:=TEMP;
TEMP:=NPM[X];
NPM[X]:=NPM[Z];
NPM[Z]:=TEMP;
END;
3: GOTO EXIT;
end;
clrscr;
gotoxy(5,4);write(garis);
gotoxy(5,5);write('no');
gotoxy(9,5);write ('NPM');
gotoxy(20,5);write('nama');
gotoxy(37,5);write('Kelas');
gotoxy(47,5);write ('paraf');
gotoxy(5,6);write(garis);

bar:=7;
for i:=1 TO N DO
begin
gotoxy(5,bar);writeln(i:2);
gotoxy(9,bar);writeln(npm[i]);
gotoxy(20,bar);writeln(nama[I]);
gotoxy(37,bar);writeln (kelas[I]);
gotoxy(47,bar);writeln(i,'............');
bar:=bar + 1;
end;
gotoxy(5,bar+1);writeln(garis);
readln;
goto menu;
exit:
end.








Tidak ada komentar:

Posting Komentar