ºÝºÝߣ
Submit Search
Ctdl 2005
?
0 likes
?
128 views
H? L?i
Follow
1 of 3
Download now
Download to read offline
More Related Content
Ctdl 2005
1.
1/3 B? GI?O D?C
& ??O T?O H? v¨¤ t¨ºn th¨ª sinh:.................................................. ??I H?C HU? S? b¨¢o danh:.................................................. K? THI TUY?N SINH SAU ??I H?C N?M 2005 M?n thi: Ng?n ng? l?p tr¨¬nh (D¨¤nh cho cao h?c) Th?i gian l¨¤m: 180 ph¨²t C?u 1. Cho danh s¨¢ch li¨ºn k?t ??n m¨¤ n¨²t ??u tr? b?i bi?n con tr? First (g?i t?t l¨¤ danh s¨¢ch First) c¨® khai b¨¢o nh? trong ch??ng tr¨¬nh ch¨ªnh: TYPE TroNut=^Nut; Nut=Record Info:Integer; Next:TroNut; End; Var First:TroNut; Gi? s?, gi¨¢ tr? tr??ng Info c?a c¨¢c n¨²t thu?c danh s¨¢ch First l?n l??t l¨¤: 8, 4, 10, 9, 5. H?y cho bi?t k?t qu? in ra m¨¤n h¨¬nh khi m¨¢y th?c hi?n l?i g?i ch??ng trinh con: Sort(First) bi?t r?ng th? t?c Sort c¨® n?i dung nh? sau: Procedure Sort(F:TroNut); Var tam:integer; Procedure List(F:TroNut); Begin if F<>nil then begin write(F^.info:5);List(F^.Next); end; End; BEGIN If (F<>nil)and(F^.Next<>nil) then Begin Sort(F^.Next); If F^.info > F^.Next^.info then Begin Tam:=F^.info; F^.info:=F^.Next^.info; F^.next^.info:=tam; List(First); writeln; Sort(F^.Next); End; End; END; C?u 2. Th?ng tin v? c¨¢c m?n h?c ???c ?¨¤o t?o t?i m?t khoa c?a m?t tr??ng ??i h?c c¨® th? ???c l?u tr? trong m?t danh s¨¢ch li¨ºn k?t ??n v?i n¨²t ??u ???c tr? b?i FirstS c¨® khai b¨¢o nh? sau ? ch??ng tr¨¬nh ch¨ªnh: Type st30=String[30]; TroMH=^NutMH; Tr¨¬nh b¨¤y: Tr?n Ho¨¤i Nh?n
2.
2/3 NutMH=record MaMH:integer; {M? m?n
h?c: tr??ng kh¨®a} TenMH:St30; {T¨ºn m?n h?c} SoDVHT:byte; {S? ??n v? h?c tr¨¬nh} Ne end; xt:TroMH; {??a ch? n¨²t ti?p theo trong danh s¨¢ch} Var FirstS:TroMH; a. Vi?t h¨¤m Function Addr(First: TroMH; BMaMH:integer):TroMH; tr? v? ??a ch? c?a n¨²t thu?c danh s¨¢ch FirstS c¨® m? m?n h?c l¨¤ BMaMH, ho?c tr? v? gi¨¢ tr? NIL n?u kh?ng c¨® n¨²t n¨¤o c¨® m? m?n h?c l¨¤ BMaMH. b. ?? qu?n l? c¨¢c m?n h?c ???c ph?n c?ng gi?ng d?y c?a m?i gi¨¢o vi¨ºn, ng??i ta l?i s? d?ng m?t danh s¨¢ch li¨ºn k?t ??n (g?i l¨¤ danh s¨¢ch gi¨¢o vi¨ºn) v?i n¨²t ??u ???c tr? b?i con tr? FirstT. M?i n¨²t c?a danh s¨¢ch gi¨¢o vi¨ºn l¨¤ m?t b?n ghi g?m 4 tr??ng: tr??ng MaGV ?? l?u m? gi¨¢o vi¨ºn (l¨¤ tr??ng kh¨®a), tr??ng HoTenGV ?? l?u h? t¨ºn gi¨¢o vi¨ºn, tr??ng Down l?u ??a ch? c?a n¨²t ti?p theo, v¨¤ tr??ng DSM l?u ??a ch? n¨²t ??u c?a m?t danh s¨¢ch kh¨¢c ch?a m? c?a m?n h?c do gi¨¢o vi¨ºn ?¨® ??m nhi?m (g?i l¨¤ danh s¨¢ch m?n h?c). M?i n¨²t c?a danh s¨¢ch m?n h?c l¨¤ m?t b?n ghi g?m 2 tr??ng: MaM ?? l?u m? m?n h?c ?? ???c ??ng k? trong danh s¨¢ch FirstS v¨¤ tr??ng Tiep l?u ??a ch? c?a n¨²t ti?p theo. L?u ? r?ng: ? Danh s¨¢ch gi¨¢o vi¨ºn ???c s?p theo th? t? t?ng d?n c?a MaGV. ? Cho bi?t khai b¨¢o b? sung c?a c?u tr¨²c d? li?u n¨®i tr¨ºn nh? sau: type St25=String[25]; st8=string[8]; TroM=^NutM; NutM=record MaM:integer; Tiep: TroM; end; TroGV=^NutGV; NutGV=record MaGV:st8; HoTenGV:st25; down: TroGV; DSM: TroM; end; var FirstT:TroGV; Vi?t hai th? t?c: + Procedure ListOfSubjects(FirstT:TroGV; BMaGV:st8); ?? li?t k¨º c¨¢c m?n h?c do gi¨¢o vi¨ºn c¨® m? gi¨¢o vi¨ºn l¨¤ BMaGV ??m nhi?m theo m?u sau: STT T¨ºn m?n h?c S? ??n v? h?c tr¨¬nh ¡ ¡ ¡ Tr¨¬nh b¨¤y: Tr?n Ho¨¤i Nh?n
3.
3/3 + Procedure ListOfTeachers(FirstT:TroGV;
BMaM:integer); ?? li?t k¨º c¨¢c gi¨¢o vi¨ºn ??m nhi?m m?n h?c c¨® m? m?n h?c l¨¤ BMaM theo m?u sau: STT H? v¨¤ t¨ºn gi¨¢o vi¨ºn ¡ ¡ C?u 3. Cho tr??c c?y nh? ph?n Top (n¨²t g?c tr? b?i Top) c¨® khai b¨¢o nh? sau: type TroNutTrenCay = ^NutTrenCay; NutTrenCay = record Value:integer; Left,Right:TroNutTrenCay; end; var Top:TroNutTrenCay; a. Vi?t h¨¤m Function Muc(Top,p:TroNutTrenCay):word; tr? v? gi¨¢ tr? l¨¤ m?c (level) c?a m?t n¨²t thu?c c?y nh? ph?n Top ???c tr? b?i con tr? P. b. ?? bi?u di?n m?t h¨¤ng ??i, ng??i ta c¨® th? s? d?ng m?t danh s¨¢ch li¨ºn k?t ??n v?i n¨²t ??u (l?i tr??c) v¨¤ n¨²t cu?i (l?i sau) l?n l??t tr? b?i First v¨¤ Last. Ngo¨¤i ra m?i n¨²t tr¨ºn danh s¨¢ch n¨¤y c¨°n c¨® th? l?u ??a ch? c?a m?t n¨²t thu?c c?y nh? ph?n Top. C? th? ta c¨® khai b¨¢o b? sung nh? sau: type TroNutTrenDS=^NutTrenDS; NutTrenDS = record Info: TroNutTrenCay; {l?u ??a ch? c?a m?t n¨²t thu?c c?y nh? ph?n Top} Next: TroNutNutTrenDS; {l?u ??a ch? n¨²t ti?p trong danh s¨¢ch} end; var First, Last: TroNutTrenDS; Vi?t hai th? t?c: + Procedure InsertQueue(var First,Last: TroNutTrenDS; X: TroNutTrenCay); ?? b? sung m?t n¨²t m¨¤ tr??ng Info c¨® gi¨¢ tr? b?ng X t?i v? tr¨ª l?i sau Last. + Procedure DeleteQueue(var First,Last: TroNutTrenDS; var X: TroNutTrenCay); ?? lo?i b? m?t n¨²t t?i v? tr¨ª l?i tr??ng First v¨¤ g¨¢n gi¨¢ tr? tr??ng Info c?a n¨²t n¨¤y cho tham bi?n X. c. Vi?t th? t?c Procedure LietKe(Top: TroNutTrenCay); nh?m li?t k¨º gi¨¢ tr? tr??ng Value c?a m?i n¨²t tr¨ºn c?y nh? ph?n Top, v?i y¨ºu c?u: ? Th? t? c¨¢c n¨²t ???c li?t k¨º l¨¤ theo th? t? t?ng d?n c?a m?c c¨¢c n¨²t tr¨ºn c?y. ? C¨¢c n¨²t c¨® c¨´ng m?c ???c li?t k¨º theo th?c t? t? tr¨¢i sang ph?i. Ghi ch¨²: C¨¢n b? coi thi kh?ng ???c gi?i th¨ªch g¨¬ th¨ºm. Tr¨¬nh b¨¤y: Tr?n Ho¨¤i Nh?n
Download