记录编号 244 评测结果 AAAAAAAAAA
题目名称 [NOIP 2007]字符串的展开 最终得分 100
用户昵称 Gravatarname:弓虽 是否通过 通过
代码语言 Pascal 运行时间 0.004 s
提交时间 2008-07-17 19:51:50 内存使用 0.12 MiB
显示代码纯文本
program expand(input,output,f1,f2);
 var
  p1,p2,p3:longint;
  i,j,k,z,l,d:longint;
  s:string;
  ans:array [1..10000] of char;
  f1,f2:text;
  flag:boolean;
begin
 assign(f1,'expand.in');
 assign(f2,'expand.out');
 reset(f1);
 rewrite(f2);
 readln(f1,p1,p2,p3);
 readln(f1,s);
 close(f1);
 l:=length(s);
 for i:=1 to 10000 do ans[i]:=' ';
  for i:=1 to l do begin
  flag:=false;
   if (s[i]='-')and (i<>1) then begin
   if (s[i-1]>='0')and(s[i-1]<='9')and(s[i+1]>='0')and(s[i+1]<='9')and(s[i-1]<s[i+1]) then flag:=true;
   if (s[i-1]>='a')and(s[i-1]<='z')and(s[i+1]>='a')and(s[i+1]<='z')and(s[i-1]<s[i+1]) then flag:=true;
    if flag=false then begin
     j:=j+1;
     ans[j]:=s[i]; end;
   if flag=true then begin
   k:=0;
    while s[i+1]<>chr(ord(s[i-1])+k+1)
    do begin
     k:=k+1;
      for z:=1 to p2 do begin
         j:=j+1;
         if p3=1 then
        case p1 of
        1:ans[j]:=(chr(ord(s[i-1])+k));
        2: if (s[i-1]>='a') and (s[i-1]<='z') then
           ans[j]:=chr(ord(s[i-1])+k-32) else
           ans[j]:=chr(ord(s[i-1])+k);
        3:ans[j]:='*';
         end
            else
          case p1 of
          1:ans[j]:=chr(ord(s[i+1])-k);
          2: if (s[i+1]>='a') and (s[i+1]<='z') then
            ans[j]:=chr(ord(s[i+1])-k-32) else
             ans[j]:=chr(ord(s[i+1])-k);
          3:ans[j]:='*';
          end;{case}
          end;{i}
          end;{while}
          end;
          end {if flag=ture}
          else begin
           j:=j+1; ans[j]:=s[i];
           end;{else}
          end;{for}
         for d:=1 to j do write(f2,ans[d]);
        close(f2);
        end.