📄 s_4_1.pas
字号:
PROGRAM studentform(input,output);
CONST
n=3;
TYPE
link=^form;
form=
RECORD
name:string[25];
sex:string[10];
class:string[25];
age:15..28;
next:link;
END;
VAR
base,p:link;
tempname:string[25];
choice:char;
PROCEDURE readinfo(VAR box:link);{学生信息读入}
VAR
p:link;
i:integer;
BEGIN
FOR i:=1 to n DO
BEGIN
new(p);
WITH p^ DO
BEGIN
readln(name);
readln(sex);
readln(class);
readln(age);
END;
p^.next:=box;
box:=p;
END;
END;
PROCEDURE view(m:link);{学生信息显示}
BEGIN
writeln;
writeln('The form at present:');
writeln('name':25,'sex':10,'class':25,'age':5);
writeln('=================================================================');
WHILE m<>NIL DO WITH m^ DO
BEGIN
writeln(name:25,sex:10,class:25,age:5);
m:=m^.next;
END;
writeln('=================================================================');
writeln;
END;
PROCEDURE scanst(stname:string;VAR stu:link);{查找学生信息}
BEGIN
WHILE stu^.name<>stname DO
stu:=stu^.next;
END;
PROCEDURE writeinfo(st:link);{输出学生信息}
BEGIN
WITH st^ DO
writeln(name:25,sex:10,class:25,age:5);
END;
PROCEDURE deleteinfo(tom:link;VAR dick:link);{删除学生信息}
VAR
here:link;
BEGIN
IF tom=dick
THEN dick:=tom^.next
ELSE BEGIN
here:=dick;
WHILE here^.next<>tom DO
here:=here^.next;
here^.next:=tom^.next;
END;
END;
BEGIN
base:=NIL;
readinfo(base);
view(base);
writeln('Search one student?(Y/N)');
REPEAT
readln(choice);
CASE choice OF
'Y','y':BEGIN
p:=base;
writeln('Tyep the name of the student:');
readln(tempname);
scanst(tempname,p);
writeinfo(p);
writeln;
writeln('Search another one?(Y/N)');
END;
END;
UNTIL (choice<>'y')and(choice<>'Y');
writeln('Delete one student?(Y/N)');
REPEAT
readln(choice);
CASE choice OF
'Y','y':BEGIN
p:=base;
writeln('Tyep the name of the student:');
readln(tempname);
scanst(tempname,p);
deleteinfo(p,base);
writeln('The information of the student delete successfully!');
writeln;
writeln('Delete another one?(Y/N)');
END;
END;
UNTIL (choice<>'y')and(choice<>'Y');
view(base);
END.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -