这题嘛,直接按照题意照做即可,就是要小心一点啊。。。
#include<cstdio>
#include<cstring>
using namespace std;
int p1,p2,p3,len,c[110];
char s[110];
int main()
{
freopen("expand.in","r",stdin);
freopen("expand.out","w",stdout);
scanf("%d%d%d
%s",&p1,&p2,&p3,s+1);
len=strlen(s+1);
for (int i=1;i<=len;i++)
if (s[i]>='a' && s[i]<='z') c[i]=1;
else if (s[i]=='-') c[i]=2; else c[i]=3;
for (int i=1;i<=len;i++)
if (s[i]=='-' && c[i-1]==c[i+1] && c[i-1]!=2 && s[i-1]<s[i+1])
{
if (p1==3)
{
for (int j=1;j<=(s[i+1]-s[i-1]-1)*p2;j++) printf("*");
}
else if (p3==1)
{
if (c[i-1]==3 || p1==1)
{
for (char c=s[i-1]+1;c<s[i+1];c++)
for (int i=1;i<=p2;i++) printf("%c",c);
}
else
{
for (char c=s[i-1]+1;c<s[i+1];c++)
for (int i=1;i<=p2;i++) printf("%c",c-32);
}
}
else
{
if (c[i-1]==3 || p1==1)
{
for (char c=s[i+1]-1;c>s[i-1];c--)
for (int i=1;i<=p2;i++) printf("%c",c);
}
else
{
for (char c=s[i+1]-1;c>s[i-1];c--)
for (int i=1;i<=p2;i++) printf("%c",c-32);
}
}
}
else printf("%c",s[i]);
return 0;
}