坑人的题目啊~~~~~,虽然说是个模拟题,但是还不是那么好拿分的,一定要细心。
本人的得分顺序:第一次40,第二次50,第三次90,第四次100……
本题需要注意的地方,也是题目中没有说明的地方(要靠选手的理解能力了):
1:只有减号两侧同为数字或同为字母时才能展开。
2:减号可以位于字符串的头部,也可以位于字符串的尾部。
3:减号可以是一个,也可以是多个。
本人的得分顺序:第一次40,第二次50,第三次90,第四次100……
本题需要注意的地方,也是题目中没有说明的地方(要靠选手的理解能力了):
1:只有减号两侧同为数字或同为字母时才能展开。
2:减号可以位于字符串的头部,也可以位于字符串的尾部。
3:减号可以是一个,也可以是多个。
PS:另开一个字符串变量ans,直接记录答案,不用在原字串上操作。
program expand;
var
p1,p2,p3:longint;
s,ans:ansistring;
procedure init;
begin
ans:='';
readln(p1,p2,p3);
readln(s);
end;
procedure main;
var
i,k,c:longint;
j:char;
temp:ansistring;
begin
for i:=1 to length(s) do
begin
if s[i]<>'-' then ans:=ans+s[i];
if s[i]='-' then
begin
c:=0;
if i=length(s) then
begin
ans:=ans+'-';
continue;
end;
if i=1 then
begin
ans:=ans+'-';
continue;
end;
if (s[i+1]='-') or (s[i-1]='-') then
begin
ans:=ans+'-';
continue;
end;
if ((ord(s[i-1])>=48) and (ord(s[i-1])<=57) and (ord(s[i+1])>=65) and (ord(s[i+1])<=122)) or ((ord(s[i+1])>=48) and (ord(s[i+1])<=57) and (ord(s[i-1])>=65) and (ord(s[i-1])<=122)) then
begin
ans:=ans+'-';
continue;
end;
if ord(s[i-1])=ord(s[i+1])-1 then continue;
if s[i-1]>=s[i+1] then
begin
ans:=ans+s[i];
continue;
end;
if s[i-1]<s[i+1] then
begin
if (ord(s[i-1])-48>=0) and (ord(s[i-1])-48<=10) then c:=32;
temp:='';
if p3=1 then
begin
for j:=chr(ord(s[i-1])+1) to chr(ord(s[i+1])-1) do
begin
for k:=1 to p2 do
begin
if p1=1 then temp:=temp+j;
if p1=2 then temp:=temp+chr(ord(j)-32+c);
if p1=3 then temp:=temp+'*';
end;
end;
end;
if p3=2 then
begin
for j:=chr(ord(s[i+1])-1) downto chr(ord(s[i-1])+1) do
begin
for k:=1 to p2 do
begin
if p1=1 then temp:=temp+j;
if p1=2 then temp:=temp+chr(ord(j)-32+c);
if p1=3 then temp:=temp+'*';
end;
end;
end;
ans:=ans+temp;
end;
end;
end;
end;
begin
assign(input,'expand.in'); reset(input);
assign(output,'expand.out'); rewrite(output);
init;
main;
writeln(ans);
close(input); close(output);
end.