CLS
TYPE MHS
NAMA AS STRING * 30
NPM AS STRING * 8
KELAS AS STRING * 5
END TYPE
INPUT "MASUKAN JUMLAH MAHASISWA "; JMH
CLS
DIM MAHASISWA(JM) AS MHS
FOR I = 1 TO JM STEP 1
PRINT " DATA KE -"; I
PRINT " "
INPUT "NAMA :", MAHASISWA(I).NAMA
INPUT "NPM :", MAHASISWA(I).NPM
INPUT "KELAS :", MAHASISWA(I).KELAS
CLS
NEXT I
CLS
PRINT "MENU"
PRINT "1.SORT BY NAME"
PRINT "2.SORT BY CLASS"
PRINT "3.EXIT"
INPUT "MASUKAN PILIHAN : ", X
SELECT CASE X
CASE 1
CASE 2
PRINT "ANGKA BESAR"
CASE ELSE
PRINT "PERINTAH YANG DI MASUKAN 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 "NPM NAMA KELAS "
PRINT "----------------------------------------"
FOR I = 1 TO JMH
PRINT MAHASISWA(I).NPM; , MAHASISWA(I).NAMA; MAHASISWA(I).KELAS
NEXT I
PRINT "----------------------------------------"
END
contoh data :
hasil :
Tidak ada komentar:
Posting Komentar