{Program Nilai Mahasiswa Menggunakan Array Di Dalam Record}
Uses WinCrt ;
Type
nilai_mahasiswa = Record
Nim : String[9] ;
Nama : String[25] ;
Nilai : real ;
End ;
Var
mhs: Array[1..20] of nilai_mahasiswa;
i, j, n : integer ;
T1, T2 : String ;
T3 : real ;
Begin
Write('Banyak mahasiswa = ') ; ReadLn(n);
For i := 1 to n do
Begin
With mhs[i] do
Begin
Writeln('Data ke ',i);
Write('N I M = '); ReadLn(Nim) ;
Write('Nama = '); ReadLn(Nama) ;
Write('Nilai = '); ReadLn(Nilai) ;
End ;
End ;
For i := 1 to n do
Begin
For j := i to n do
Begin
If mhs[i].Nim > mhs[j].Nim then
Begin
T1 := mhs[i].Nim ;
mhs[i].Nim := mhs[j].Nim ;
mhs[j].Nim := t1 ;
T2 := mhs[i].Nama ;
mhs[i].Nama := mhs[j].Nama ;
mhs[j].Nama := T2 ;
T3 := mhs[i].Nilai;
mhs[i].Nilai := mhs[j].Nilai ;
mhs[j].Nilai := T3 ;
End ;
End ;
End ;
WriteLn('----------------------------------------------------') ;
WriteLn(' Soritng Berdasarkan N I M ') ;
WriteLn('----------------------------------------------------') ;
WriteLn(' D A T A N I L A I M A H A S I S W A ') ;
WriteLn('----------------------------------------------------') ;
WriteLn('index | N I M | NAMA MAHASISWA | N I L A I ') ;
WriteLn('-----------------------------------------------------') ;
For i:= 1 to n do
With mhs[i] do
Writeln('[',i:3,'] | ',Nim:9,' | ',Nama:25,' | ',Nilai:8:0) ;
WriteLn('---------------------------------------------------') ;
End.
0 komentar:
Posting Komentar