比赛 |
暑假培训一 |
评测结果 |
AAAAAAAAAA |
题目名称 |
字符串的展开 |
最终得分 |
100 |
用户昵称 |
苏轼 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-07-17 10:58:24 |
显示代码纯文本
program cch(input,output,f1,f2);
var
f1,f2:text;
a:array[1..20000] of char;
k,i,c1,c2,q,p1,p2,p3,l:integer;
s:string;
x,y:char;
procedure solve1(c1,c2:integer);
var
i,x1,y1,j:integer;
s1:string;
flag:boolean;
begin
flag:=true; s1:='';
if p1=1 then begin x1:=c1+1; y1:=c2-1; end;
if p1=2 then begin x1:=(c1-97+65)+1; y1:=(c2-97+65)-1; end;
if p1=3 then begin x1:=c1+1; y1:=c2-1; flag:=false; end;
if p3=1 then
if flag then
for i:=x1 to y1 do
for j:=1 to p2 do s1:= s1+chr(i)
else for i:=x1 to y1 do
for j:=1 to p2 do s1:=s1+'*';
if p3=2 then
if flag then
for i:=y1 downto x1 do
for j:=1 to p2 do s1:=s1+chr(i)
else for i:=y1 downto x1 do
for j:=1 to p2 do s1:=s1+'*';
for i:=1 to length(s1) do begin
inc(k);
a[k]:=s1[i];
end;
end;
procedure solve2(c1,c2:integer);
var
i,x1,y1,j:integer;
s1:string;
flag:boolean;
begin
flag:=true; s1:='';
x1:=c1+1; y1:=c2-1;
if p1=3 then flag:=false;
if p3=1 then
if flag then
for i:=x1 to y1 do
for j:=1 to p2 do s1:= s1+chr(i)
else for i:=x1 to y1 do
for j:=1 to p2 do s1:=s1+'*';
if p3=2 then
if flag then
for i:=y1 downto x1 do
for j:=1 to p2 do s1:=s1+chr(i)
else for i:=y1 downto x1 do
for j:=1 to p2 do s1:=s1+'*';
for i:=1 to length(s1) do begin
inc(k);
a[k]:=s1[i];
end;
end;
begin
assign(f1,'expand.in');
assign(f2,'expand.out');
reset(f1);
rewrite(f2);
readln(f1,p1,p2,p3);
readln(f1,s);
l:=length(s);
k:=0;
while l<>0 do
begin
q:=pos('-',s);
if q=0 then begin
for i:=1 to length(s) do begin
inc(k);
a[k]:=s[i];
end;
break;
end;
for i:=1 to q do begin
inc(k);
a[k]:=s[i];
end;
x:=s[q-1]; y:=s[q+1];
if (q=1)or (q=length(s)) then x:=y;
c1:=ord(x); c2:=ord(y);
if (x in ['a'..'z'])and(y in ['a'..'z']) then
if c1<c2 then begin
dec(k);
solve1(c1,c2);
end;
if (x in ['0'..'9'])and(y in ['0'..'9']) then
if c1<c2 then begin
dec(k);
solve2(c1,c2); end;
delete(s,1,q);
l:=length(s);
end;
for i:=1 to k do write(f2,a[i]);
close(f1);
close(f2);
end.