题目链接:HDU 1020【Encoding】
思路
简单模拟,计算相同字母的连续子串个数。
代码
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
const int N = 500 + 10;
void solve() {
string s;
cin >> s;
int len = s.length();
for (int i = 0; i < len; i++) {
int j = i;
while (s[i] == s[j] && j < len)
j++;
if (j - i != 1) cout << j - i;
cout << s[i];
i = j - 1;
}
cout << endl;
return;
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
标签:HDU,1020,Encoding,int,len,include
From: https://www.cnblogs.com/againss/p/18325606