80pts救救我
查看原帖
80pts救救我
779036
封禁用户楼主2023/7/29 20:30
#include<bits/stdc++.h>
using namespace std;
void f1(int p1,int p2,int p3,string s){
    string res="";
    for(int i=0;i<s.length();i++){
        if(s[i]=='-'&&i>0&&i<s.length()-1&&s[i-1]<s[i+1]&&((s[i-1]>='a'&&s[i-1]<='z'&&s[i+1]>='a'&&s[i+1]<='z')||(s[i-1]>='0'&&s[i-1]<='9'&&s[i+1]>='0'&&s[i+1]<='9'))){
            for(char c=s[i-1]+1;c<s[i+1];c++){
                char temp=c;
                if(p1==2){
                    if(c>='a'&&c<='z'){
                        temp=c-'a'+'A';
                    }
                }
                for(int j=0;j<p2;j++){
                    if(p1==3){
                        res+='*';
                    }else{
                        res+=temp;
                    }
                }
            }
        }else{
            res+=s[i];
        }
    }
    if(p3==2&&res!=s){
        for(int begin=0,end=res.find('-');end<=res.length();
            begin=end,end=res.find('-',end+1)){
            if(end!=res.length() + 1){
                reverse(res.begin() + begin + 1, res.begin() + end);
            }else{
                reverse(res.begin() + begin + 1, res.end());
            }
        }
    }
    cout<<res<<"\n";
}
int main(){
    int p1,p2,p3;
    string s;
    cin>>p1>>p2>>p3>>s;
    f1(p1,p2,p3,s);
    return 0;
}
2023/7/29 20:30
加载中...