# Include <iostream> # include <string> using namespace STD; // convert the numeric string format to the character that appears in the original string + the number of consecutive occurrences of the character p231string func (string Str) {// string strchar; // string strnum; string ret; int Len = Str. length (); For (INT I = 0; I <Len; I ++) {// when it is a continuous character, skip and add an int COUNT = 1; while (STR [I] = STR [I + 1]) {count ++; I ++ ;} // count consecutive characters and the number of occurrences to the result string // strchar + = STR [I]; RET + = STR [I]; char TMP [10]; sprintf_s (TMP, "% d", count); // replace ITOA with // strnum + = TMP; RET + = TMP;} return ret;} int main () {/* char * P = "Hello World"; cout <strlen (p) <Endl; string STR; STR + = 'a'; STR + = 'B '; cout <STR <Endl; cout <Str. length () <Endl; */string STR ("111111111111223333"); cout <func (STR) <Endl; return 0 ;}