题解
2024-08-07 14:44:23
发布于:上海
2阅读
0回复
0点赞
我过关!
代码:
#include <iostream>
using namespace std;
string itos(int input){
if(input<10) {
string s="x";
s[0]='0'+input;
return s;
}
string s = itos(input/10) + itos(input%10);
return s;
}
string once(string input){
int in1 = 0,in2;
string ans = "";
char ch3;
while (in1<input.size()){
in2=0;
ch3=input[in1];
while(input[in1]==ch3){
in1++;
in2++;
}
ans += itos(in2)+ch3;
}
return ans;
}
int main(){
string s;
int n;
cin>>s>>n;
for(int i = 0; i<n; i++){
s = once(s);
}
cout<<s;
return 0;
}
这里空空如也
有帮助,赞一个