contoh program sortir file mahasiswa
CLS
TYPE MHS
NAMA AS
STRING * 30
NPM AS
STRING * 8
KELAS AS STRING * 5
END TYPE
INPUT "MASUKKAN JUMLAH MAHASISWA";
JM
DIM MAHASISWA(JM) AS MHS
FOR I = 1 TO JM STEP 1
PRINT " DATA KE -"; I
INPUT "NAMA :", MAHASISWA(I).NAMA
INPUT "NPM :", MAHASISWA(I).NPM
INPUT "KELAS :", MAHASISWA(I).KELAS
NEXT I
CLS
PRINT "MENU"
PRINT "1.SORT BY CLASS"
PRINT "2.EXIT"
INPUT "MASUKKAN PILIHAN : ", X
SELECT CASE X
CASE 1
IF MAHASISWA(J).KELAS > MAHASISWA(J +
1).KELAS THEN
SWAP MAHASISWA(J), MAHASISWA(J + 1)
SEMPURNA = 0
END IF
CASE 2
PRINT "ANGKA BESAR"
CASE ELSE
PRINT "PERINTAH YANG DI MASUKKAN
SALAH"
END SELECT
FOR I = (JM - 1) TO 1 STEP -1
SEMPURNA = 1
FOR J = 1 TO I
IF MAHASISWA(J).KELAS > MAHASISWA(J +
1).KELAS THEN
SWAP MAHASISWA(J), MAHASISWA(J + 1)
SEMPURNA = 0
END IF
NEXT J
IF SEMPURNA = 1 THEN
I = 0
END IF
NEXT I
CLS
PRINT "DATA MAHASISWA"
PRINT
PRINT
"---------------------------------------------------"
PRINT "NPM NAMA KELAS "
PRINT "---------------------------------------------------"
FOR I = 1 TO JM
PRINT MAHASISWA(I).NPM; , MAHASISWA(I).NAMA;
MAHASISWA(I).KELAS
NEXT I
PRINT
"---------------------------------------------------"
END
Tidak ada komentar:
Posting Komentar