字符串的展开

来源:互联网 发布:邮票交易软件下载 编辑:程序博客网 时间:2024/06/05 02:42
var
 p1,p2,p3,i,j,n,l:longint;
 ic,k:char;
 s,ss,s2:ansistring;
 function check(c,cc:char):boolean;
 var biao:longint;
 begin
  biao:=0;
  if ((c in['a'..'z'])and(cc in['a'..'z']))or((c in['0'..'9'])and(cc in['0'..'9'])) then biao:=1;
  if (ord(cc)-ord(c)>1)and(c<>'-')and(cc<>'-')and(biao=1) then exit(true);
  exit(false);
 end;
 function down(s:ansistring):ansistring;
 var i1,j1:longint;
 begin
  down:='';
  for i1:=length(s) downto 1 do
  down:=down+s[i1];
  exit(down);
 end;
begin
 readln(p1,p2,p3);
 readln(s);
 write(s[1]);
 for i:=2 to length(s)-1 do
  if s[i]='-' then
  begin
   ss:='';
   if (not check(s[i-1],s[i+1]))and(ord(s[i+1])-ord(s[i-1])<>1) then write('-')
   else
   if check(s[i-1],s[i+1]) then
    begin
    if p1=1 then
    begin
     for ic:=chr(ord(s[i-1])+1)to chr(ord(s[i+1])-1) do
      for j:=1 to p2 do
      ss:=ss+ic;
    end;
    if p1=2 then
    begin
     for ic:=chr(ord(s[i-1])+1)to chr(ord(s[i+1])-1) do
      for j:=1 to p2 do
      ss:=ss+upcase(ic);
    end;
    if p1=3 then
    begin
     for ic:=chr(ord(s[i-1])+1)to chr(ord(s[i+1])-1) do
      for j:=1 to p2 do
      ss:=ss+'*';
    end;
    if p3=1 then write(ss)
            else write(down(ss));
  end;
 end
 else write(s[i]);
 write(s[length(s)]);
end.
0 0
原创粉丝点击