记录编号 |
22433 |
评测结果 |
WEWEWEEEEA |
题目名称 |
学生成绩管理系统 |
最终得分 |
10 |
用户昵称 |
苏轼 |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.007 s |
提交时间 |
2010-11-19 11:21:34 |
内存使用 |
0.21 MiB |
显示代码纯文本
program as;
const maxn=2000;
type stu=record
sn,num,p:integer;
end;
var data:array[1..maxn] of stu;
fr,fw:text;n,m,lp,ls:integer;
procedure init;
var i:integer;
begin
for i:=1 to maxn do data[i].p:=-1;
assign(fr,'linet.in');reset(fr);readln(fr,n);
for i:=1 to n do
begin
readln(fr,data[i].sn,data[i].num);
if i=n then data[i].p:=0 else data[i].p:=i+1;
end;
lp:=1;ls:=n;
readln(fr,m);
assign(fw,'linet.out');rewrite(fw);
end;
procedure main;
var i,lx:integer;
procedure chazhao;
var n,num,lp1:integer;
begin
read(fr,n);lp1:=lp;
if n=0 then
begin
if lp1=0 then writeln(fw,'no') else
begin
writeln(fw,ls);
while lp1<>0 do
begin
writeln(fw,data[lp1].sn,' ',data[lp1].num);
lp1:=data[lp1].p;
end;
end;
end else
begin
read(fr,n);
while (data[lp1].sn<>n)and(lp1<>0) do lp1:=data[lp1].p;
if lp1=0 then writeln(fw,'no') else writeln(fw,data[lp1].sn,' ',data[lp1].num);
end;
end;
procedure ins;
var n,lp1,x,y,z,i,ii:integer;
begin
read(fr,n);
for ii:=1 to n do
begin
read(fr,x,y,z);lp1:=lp;
i:=0;while (lp1<>0)and(data[lp1].sn<>y) do
begin inc(i);lp1:=data[lp1].p;end;
lp1:=lp;
if i<ls then writeln(fw,'dup') else
if x=0 then
begin
i:=1;
while data[i].p>=0 do inc(i);
data[i].sn:=y;data[i].num:=z;data[i].p:=lp;lp:=i;inc(ls);
end else
begin
dec(x);
while (x<>0)and(lp1<>0) do begin dec(x);lp1:=data[lp1].p;end;
if lp1=0 then writeln(fw,'out') else
begin
i:=1;while data[i].p>=0 do inc(i);
data[i].p:=data[lp1].p;data[lp1].p:=i;
data[i].sn:=y;data[i].num:=z;inc(ls);
end;
end;
end;
readln(fr);
end;
procedure dele;
var i,n,x,lp1,lp2:integer;
begin
read(fr,n);
for i:=1 to n do
begin
if ls=0 then writeln(fw,'error') else
begin
read(fr,x);lp1:=lp;lp2:=lp;
while (x<>data[lp1].sn)and(lp1<>0) do begin lp2:=lp1;lp1:=data[lp1].p;end;
if lp1=0 then writeln(fw,'error') else
begin
if lp1=lp then begin lp:=data[lp].p;data[lp].p:=-1;end else
begin data[lp2].p:=data[lp1].p;data[lp1].p:=-1;end;dec(ls);
end;
end;
end;
end;
begin
for i:=1 to m do
begin
read(fr,lx);
if lx=1 then chazhao;
if lx=2 then ins;
if lx=3 then dele;
end;
close(fr);close(fw);
end;
BEGIN
init;
main;
END.