HOJ 1020

来源:互联网 发布:如何防范sql注入式攻击 编辑:程序博客网 时间:2024/05/22 08:11
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
int n;

cin >> n;
while (n--)
{
string str;
string temp;
cin >> str;
int len = str.length();
temp += str[len-1];
int count = 1;
for (int i = len-2; i >=0; i--)
{

if (str[i] != str[i +1 ])
{
if (count != 1)


ostringstream s1;
s1 << count;
string s2 = s1.str();
for (int k = s2.length() - 1; k >= 0;k--)
temp += s2[k];
s1.clear();
}
temp += str[i];
count = 1;
}
else
{
count++;
}
}
if (count != 1)

ostringstream s2;
s2<< count;
string s3 = s2.str();
for (int k = s3.length() - 1; k >= 0; k--)
temp += s3[k];

s2.clear();
}
int size = temp.length();
for (int j = size-1; j >= 0; j--)
{
cout << temp[j];
}
cout << endl;
}
return 0;
}
0 0