压缩函数~~
2024-10-08 19:42:20
发布于:上海
9阅读
0回复
0点赞
#include<iostream>
#include<cstring>
using namespace std;
void print (string s,int l,int r){
for(int i=l;i<=r;i++){
cout<<s[i];
}
}
void f(string s){
int len=s.size()-1;
if(s[0]=='o'){
cout<<"MARCO";
print(s,1,len);
}
else if(s[0]=='c'&&s[1]=='o'){
cout<<"MARCO";
print(s,2,len);
}
else if(s[0]=='r'&&s[1]=='c'&&s[2]=='o'){
cout<<"MARCO";
print(s,3,len);
}
else if(s[0]=='a'&&s[1]=='r'&&s[2]=='c'&&s[3]=='o'){
cout<<"MARCO";
print(s,4,len);
}
else if(s[0]=='m'&&s[1]=='a'&&s[2]=='r'&&s[3]=='c'&&s[4]=='o'){
cout<<"MARCO";
print(s,5,len);
}
else cout<<s;
}
int main(){
int t;
cin>>t;
while(t--){
string s;
cin>>s;
f(s);
cout<<"\n";
}
}
这里空空如也
有帮助,赞一个