22、<简单>总结相同的数字 📅 2026/7/6 1:21:47 #include iostream #include string using namespace std; int main() { // 程序功能字符串压缩单个字母不标数字连续重复标长度字母 cout 输入要求仅小写英文字母长度不超过255 endl; cout 请输入待压缩字符串; string str; cin str; string result; int length str.size(); int index 0; while (index length) { char current str[index]; int count 1; // 统计当前字母连续出现多少次 while (index 1 length str[index 1] current) { count; index; } // 多于1个才拼接数字 if (count 1) { result result to_string(count); } result current; index; } cout \n压缩完成压缩后的字符串 result endl; return 0; }