µo«H¤H¡G LinJarway (ªü§À) ¬ÝªO¡Gmath89
¤é´Á¡G Fri Jun 13 21:26:04 1997
¼ÐÃD¡G pµ{Lab6
¨Ó·½¡G ¤¤¤s¤j¾Ç Formosa BBS Client
¤µ¤Ñ¤U¤È§Ú¨ì¢Ð¼Ó®É¡Aµo²{pµ{ªºLAB6¦n¹³«Ü¤Ö¤H¥æ¡A
¦Ó¥B¡A§Ú¤SÅ¥¨ì¦³«Ü¦h¤HÁÙ¨S¼g¥X¨Ó¡A
§Ú·Q¦A¤£¥æªº¸Ü¡A®É¶¡´N¨ì¤F¡A©Ò¥H§Ô¤£¦í¥´¤F¤@¥÷¶§¬Kª©ªºLAB6
ÁÙ¨S¼gªº¤H´N±N´N¤@¤U¡A§ï´XÓ¦WºÙ¥æ¤F¦n±M¤ßÀ³¥I¤U¶gªº´Á¥½¦Ò§a¡C
--------------------------------------------------------------
type ptrtype=^student;
student=record
link:ptrtype;
data:string;
end;
var id,head:array['A'..'Z'] of ptrtype;
select:char;
procedure initalize;
var i:char;
begin
for i:='A' to 'J' do
begin
new(head[i]);
head[i]^.link:=head[i];
id[i]:=head[i];
end;
end;
procedure borrow;
var tmp:ptrtype;
stdid:char;
begin
new(tmp);
write(#2,'Student ID : ');
readln(stdid);
if stdid in ['a'..'j'] then stdid:=char(ord(stdid)-32);
if stdid in ['A'..'J'] then
begin
write('Name of the Book: ');
readln(tmp^.data);
id[stdid]^.link:=tmp;
id[stdid]:=tmp;
id[stdid]^.link:=head[stdid];
end
else writeln(#1,'No such student !');
end;
procedure return;
var tmp,last:ptrtype;
stdid:char;
book:string;
found:boolean;
begin
write(#2,'Student ID : ');
readln(stdid);
if stdid in ['a'..'j'] then stdid:=char(ord(stdid)-32);
if stdid in ['A'..'J'] then
begin
write('Name of the Book: ');
readln(book);
last:=id[stdid];
id[stdid]:=head[stdid];
found:=false;
while (id[stdid]^.link<>head[stdid]) and not found do
begin
tmp:=id[stdid];
found:=(id[stdid]^.link^.data=book);
id[stdid]:=id[stdid]^.link;
end;
if found then
begin
id[stdid]:=tmp;
if last=id[stdid]^.link then last:=id[stdid];
tmp:=id[stdid]^.link;
id[stdid]^.link:=tmp^.link;
dispose(tmp);
end
else writeln(#1,'No such book!');
id[stdid]:=last;
end
else writeln(#1,'No such student !');
end;
procedure list;
var i:char;
last:ptrtype;
begin
for i:='A' to 'J' do
begin
last:=id[i];
id[i]:=head[i]^.link;
if id[i]<>head[i] then writeln('Student ',i,' :');
while id[i]<>head[i] do
begin
writeln(id[i]^.data);
id[i]:=id[i]^.link;
end;
id[i]:=last;
end;
end;
begin
initalize;
repeat
write(#1,'Borrow/Return/List/Exit : ');
readln(select);
case select of
'B','b': borrow;
'R','r': return;
'L','l': list;
'E','e': begin end;
else writeln(#2,'Wrong Selection!!');
end;
until select in ['E','e'];
writeln(#2,'Bye~~');
end.
---------------------------------------------------------------------
PS:¼g±oÁöµM¤£¦n¡A¦ý¬O¦³¥æ´N¦n¡A¤£¬O¶Ü¡H
--
¤¤ ¤Q¡@¦~ ¦u¢{ùï¢w¡÷¤W¯¸¬°¥æ¤Í¤§¥»¡÷¥æ¤Í¬°¼g«H¤§¥»¡÷¼g«H¬°²á¤Ñ¤§¥»¢wùñ
¤g¡@¡W ùéùåùï¢w¥»¤§½H²©¬°¯¦«K¡ö¥»¤§¯¦«K¬°§¾¥´¡ö¥»¤§§¾¥´¬°¤Ñ²á¡öù÷
¤é¡@¡W ¢x ùõ¡÷¡uªü §À Á` ¬O ¤ñ ¸û §t »W ¡A
¤s 'I ¡W «h¢} ¡@¡@ §A Ì n ¦h ¦h ¼g «H Ãö ¤ß ¥L ¡K¡K¡À¡v
|