//这一题和2478差不多,只不过是字符串变长了,如果用cout频繁输出的情况下就会超时!所以用printf!
#include "iostream"
#include "string"
#include "stdio.h"
using namespace std;
int main()
{
int TestCase;
cin >> TestCase;
while (TestCase--)
{
string str;
char first;
int length, count = 0;
cin >> str;
length = str.size();
first = str[0];
for (int i = 0; i < length; i++)
{
if (str[i] == first)
{
count++;
if (i == length - 1)
printf("%d%c", count, first);
}
else
{
printf("%d%c", count, first);
first = str[i];
count = 1;
if (i == length - 1)
printf("%d%c", count, first);
}
}
cout << endl;
}
}
zoj 2886 Look and Say
最新推荐文章于 2022-02-25 21:57:21 发布