首页 > 学院 > 开发设计 > 正文

字符串的展开

2019-11-08 02:33:57
字体:
来源:转载
供稿:网友
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.
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表