#include <iostream>
#include <string>
using namespace std;
int main(){
string str;
int n;
cin>>str;
scanf("%d",&n);
for(int i = 1;i < n;i++){
int len = str.length();
string temp = "";
int cnt = 0;
char cur = str[0];
for(int j = 0;j < len;j++){
if(str[j] == cur)
cnt++;
else{
temp += cur;
temp += (cnt + '0');
cur = str[j];
cnt = 1;
}
}
temp += cur;
temp += (cnt + '0');
str = temp;
}
printf("%s",str.c_str());
system("pause");
return 0;
}
PAT | A1140 Look-and-say Sequence
最新推荐文章于 2024-03-04 14:56:44 发布