字符串水题
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> using namespace std; void work() { string st; cin >> st; int length = st.length(); int l = 1; for (int i = 1; i < length; i++) { if (st[i] != st[i - 1]) { printf("%d%c", l, st[i - 1]); l = 1; } else l++; } printf("%d%c", l, st[length - 1]); cout << endl; } int main() { //freopen("D:\\t.txt", "r", stdin); int t; scanf("%d", &t); while (t--) { work(); } return 0; }