比赛 暑假培训一 评测结果 AWWWWWWWWW
题目名称 字符串的展开 最终得分 10
用户昵称 zpl123 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-17 11:57:51
显示代码纯文本
program expand;
var
f1,f2:text;
s,s1:string;
l,p1,p2,p3:integer;

procedure step1;
var
d,i:integer;
begin
d:=pos('-',s);
if (p1=3)and
 ((s[d-1] in ['a'..'z'])and(s[d+1] in ['a'..'z'])and(ord(s[d-1])<ord(s[d+1]))or
  (s[d-1] in ['0'..'9'])and(s[d+1] in ['0'..'9'])and(ord(s[d-1])<ord(s[d+1])))then
  for i:=(ord(s[d-1])+1) to (ord(s[d+1])-1) do s1:=s1+'*'
else begin
if (s[d-1] in ['a'..'z'])and(s[d+1] in ['a'..'z'])and(ord(s[d-1])<ord(s[d+1])) then
begin
if p1=2 then
for i:=(ord(s[d-1])+1) to (ord(s[d+1])-1) do
s1:=s1+chr(i-32);
if p1=1 then
for i:=(ord(s[d-1])+1) to (ord(s[d+1])-1) do
s1:=s1+chr(i);
end;
if (s[d-1] in ['0'..'9'])and(s[d+1] in ['0'..'9'])and(ord(s[d-1])<ord(s[d+1])) then
for i:=(ord(s[d-1])+1) to (ord(s[d+1])-1) do
s1:=s1+chr(i);
end;
end;

procedure step2;
var
i,ll:integer;
ss:string;
begin
ll:=length(s1);
if p3=1 then s1:=s1;
if p3=2 then
 begin
 for i:=1 to ll do
 ss[i]:=s1[ll+1-i];
 s1:=ss;
 end;
end;

procedure step3;
var
i,j,l3:integer;
s2:string;
begin
l3:=length(s1);
s2:='';
for i:=ord(s1[1]) to ord(s1[l3]) do
 for j:=1 to p2 do s2:=s2+chr(i);
s1:=s2;
end;

procedure main;
var
e:integer;
begin
s1:=''; e:=pos('-',s);
step1;
step2;
step3;
delete(s,e,1);
insert(s1,s,e);
e:=pos('-',s);
if (e=0)or(not((s[e-1] in ['a'..'z'])and(s[e+1] in ['a'..'z'])and(ord(s[e-1])<ord(s[e+1]))or
  (s[e-1] in ['0'..'9'])and(s[e+1] in ['0'..'9'])and(ord(s[e-1])<ord(s[e+1])))) then exit;
main;
end;

procedure print;
begin
writeln(f2,s);
close(f1);
close(f2);
end;

begin
assign(f1,'expand.in');
reset(f1);
assign(f2,'expand.out');
rewrite(f2);
readln(f1,p1,p2,p3);
read(f1,s);

main;
print;

end.