1140 Look-and-say Sequence(20 分)
2018-08-07 本文已影响0人
zjh3029
#include <iostream>
#include <string>
using namespace std;
int M, N;
int main()
{
cin >> N >> M;
string str = to_string(N);
string str1;
for (int j = 1; j < M; j++)
{
int cnt = 1;
for (int i=0;i<str.size();i++)
{
if(str[i+1]==str[i])
{
cnt++;
}
else
{
str1 += str[i];
str1 += to_string(cnt);
cnt = 1;
}
}
str=str1;
str1.clear();
}
cout << str << endl;
system("pause");
return 0;
}