- 看和说
- 如112223写作113213(1个1,3个2,1个3)
#include<iostream>
using namespace std;
int main() {
cout << "实例:112223对其进行描述为113213(1个1,3个2,1个3)"<<endl;
int n,temp=0;
string s,t;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s;
t[0] = s[0];
temp = 0;
cout << "输出结果为:" ;
for (int j = 0; j < s.size(); j++) {
if (s[j] == t[0]) {
temp++;
if (j == s.size() - 1) {
cout << temp << t[0];
}
}
else {
cout << temp << t[0];
t[0] = s[j];
temp = 1;
if (j == s.size() - 1) {
cout << temp << t[0];
}
}
}
cout << endl;
}
return 0;
}