比赛 |
暑假培训一 |
评测结果 |
AWWWWWWWWW |
题目名称 |
字符串的展开 |
最终得分 |
10 |
用户昵称 |
rottenwood |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-07-17 11:49:23 |
显示代码纯文本
program expand;
type
shuzu=array[0..200]of string;
var
t,l,i,j,k,m,n,x,y,p1,p2,p3:integer;
s,s1,s2,s3:string;
f1,f2:text;
z:shuzu;
begin
assign(f1,'expand.in');reset(f1);
assign(f2,'expand.out');rewrite(f2);
readln(f1,p1,p2,p3);
readln(f1,s);
l:=length(s);
t:=1;
s2:='';
for i:=1 to l do
begin s2:='';
if s[i]='-' then begin
if ((s[i-1] in ['a'..'z'])and(s[i+1] in['a'..'z'])
or(s[i-1] in ['0'..'9'])and(s[i+1] in['0'..'9']))
and (ord(s[i-1])+1=ord(s[i+1]))
then begin
delete(s,i,1);
s1:=copy(s,t,i-t)+s2;
s3:=s3+s1;
end;
if ((s[i-1] in ['a'..'z'])and(s[i+1] in['0'..'9'])
or(s[i-1] in ['0'..'9'])and(s[i+1] in['a'..'z']))
then begin
s1:=copy(s,t,i-t+1);
s3:=s3+s1;
end;
if ((s[i-1] in ['a'..'z'])and(s[i+1] in['a'..'z'])
or(s[i-1] in ['0'..'9'])and(s[i+1] in['0'..'9']))
and (ord(s[i+1])>ord(s[i-1]))
then begin
if p1=1 then
begin
if p3=1 then
begin
for j:=ord(s[i-1])+1 to ord(s[i+1])-1 do
for k:=1 to p2 do
s2:=s2+chr(j);
end;
if p3=2 then
begin
for j:=ord(s[i+1])-1 downto ord(s[i-1])+1 do
for k:=1 to p2 do
s2:=s2+chr(j);
end;
delete(s,i,1);
s1:=copy(s,t,i-t)+s2;
s3:=s3+s1;
end;
if p1=2 then
begin
if p3=1 then
for j:=ord(s[i-1])-32+1 to
ord(s[i+1])-32-1 do
for k:=1 to p2 do
s2:=s2+chr(j);
if p3=2 then
for j:=ord(s[i+1])-32-1 downto
ord(s[i-1])-32+1 do
for k:=1 to p2 do
s2:=s2+chr(j);
delete(s,i,1);
s1:=copy(s,t,i-t)+s2;
s3:=s3+s1;
end;
if p1=3 then begin
for j:=ord(s[i-1])+1 to ord(s[i+1])-1 do
for k:=1 to p2 do
s2:=s2+'*';
delete(s,i,1);
s1:=copy(s,t,i-t)+s2;
s3:=s3+s1;
end;
end;
t:=i;
end;
end;
s1:=copy(s,t,l-t);
s3:=s3+s1;
writeln(f2,s3);
close(f2);
end.