注意那個循環(huán)次數(shù),是n-1不是n,坑死了急但,坛善,晾蜘,
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
string s;
int n, j;
cin >> s >> n;
n--;
while (n--)
{
string temp;
int i = 0, j = 0;
while (i < s.length())
{
while (s[j] == s[i] && j < s.length())j++;
temp += s[i] + to_string(j - i);
i = j;
}
s = temp;
}
cout << s;
return 0;
}