题解 | #字符串的展开#
字符串的展开
https://ac.nowcoder.com/acm/problem/16644
这个题我们就按照题意模拟一遍就好啦~
#include<bits/stdc++.h>
using namespace std;
int main(){
int p1,p2,p3;cin>>p1>>p2>>p3;
string s,ans;cin>>s;ans.push_back(s[0]);
for(int i=1;i<s.length();i++)
if(s[i]=='-'&&(isdigit(ans.back())&&isdigit(s[i+1])||isalpha(ans.back())&&isalpha(s[i+1]))&&ans.back()<s[i+1]){
int l=ans.back()+1,r=s[i+1]-1;
if(p1==2&&!isdigit(ans.back()))l-=32,r-=32;
if(p3!=2)for(int i=l;i<=r;i++)for(int j=1;j<=p2;j++)ans.push_back(p1==3?'*':i);
else if(p3==2)for(int i=r;i>=l;i--)for(int j=1;j<=p2;j++)ans.push_back(p1==3?'*':i);
}else ans.push_back(s[i]);
cout<<ans<<"\n";
}