水题,直接模拟之
// Problem#: 1491
// Submission#: 3178088
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<iostream>
#include<string>
using namespace std;
int main() {
int test;
cin >> test;
while (test--) {
string str;
cin >> str;
int count = 1;
for (int i = 0; i < str.length(); i++) {
if (str[i] == str[i + 1]) {
count++;
continue;
} else {
cout << count << str[i];
count = 1;
}
}
cout << endl;
}
}