题解 | #字符串编码#
字符串编码
http://www.nowcoder.com/practice/56a487c342a64d2ea4c3a0b0144b42d0
#include<iostream>
#include<string>
using namespace std;
int main(void) {
string str;
cin >> str;
int i = 0;
for(;i < str.size();) {
int count = 1;
int j = i + 1;
while(j<str.size() && str[i] == str[j]) {
j++;
count++;
}
cout << count << str[i];
i = j;
}
return 0;
}
拼多多笔试题考过