比赛 暑假培训一 评测结果 AAAAAAAAAA
题目名称 字符串的展开 最终得分 100
用户昵称 Hamster 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-17 11:24:38
显示代码纯文本
program expand;
var i,j,k,p1,p2,p3,o:integer;
    a:string;
    b:array[1..10000]of char;
    falg:boolean;
    fin,fout:text;
begin
 assign(fin,'expand.in');
 reset(fin);
 assign(fout,'expand.out');
 rewrite(fout);

 readln(fin,p1,p2,p3);
 readln(fin,a);

 for i:=1 to length(a) do
 begin
  falg:=false;
  if (a[i]='-')and(i<>1) then
  begin
   if (a[i-1]>='0')and(a[i-1]<='9')and(a[i+1]>='0')and(a[i+1]<='9')and(a[i-1]<a[i+1]) then falg:=true;
   if (a[i-1]>='a')and(a[i-1]<='z')and(a[i+1]>='a')and(a[i+1]<='z')and(a[i-1]<a[i+1]) then falg:=true;
   if not(falg) then
   begin
    inc(o);
    b[o]:=a[i];
   end;
   if falg then
   begin
    j:=0;
    while a[i+1]<>chr(ord(a[i-1])+j+1) do
    begin
     j:=j+1;
     for k:=1 to p2 do
     begin
      inc(o);
      if p3=1 then
      case p1 of
        1:b[o]:=(chr(ord(a[i-1])+j));
        2:if (a[i-1]>='a')and(a[i-1]<='z') then
           b[o]:=chr(ord(a[i-1])+j-32) else
           b[o]:=chr(ord(a[i-1])+j);
        3:b[o]:='*';
     end else
     case p1 of
       1:b[o]:=(chr(ord(a[i+1])-j));
       2:if (a[i+1]>='a')and(a[i+1]<='z') then
           b[o]:=chr(ord(a[i+1])-j-32) else
           b[o]:=chr(ord(a[i+1])-j);
       3:b[o]:='*';
     end;
    end;
   end;
  end;
 end else begin inc(o); b[o]:=a[i]; end;
end;

for i:=1 to o do write(fout,b[i]);

close(fin);
close(fout);
end.