对于这道题我只想说。没理解他在说什么真是个很烦躁的事。
EG:ABBCCCCAAAA——->A2B4C4A
#include <iostream>
#include <string.h>
using namespace std ;
int main(){
int n;
cin >> n;
while(n--){
string s ;
cin >> s;
int count = 1 ;
char ch = s[0];
for(int i = 1 ; i < s.length() ; i++){
if (s[i] == ch){
count++;
}
else{
if(count == 1)
cout << ch;
else
cout << count << ch;
count = 1;
ch = s[i];
}
}
if(count == 1)
cout << ch;
else
cout << count << ch;
cout<<endl;
}
}