1、请将字符串逆序,如"aabbccddeeff"转化成为"ffeeddccbbaa" #include <iostream> void ReverseStr(char* ptrStr, int len); void ReverseStr2(char* ptrSTR, int len); int main(int argc, char* argv[]) { char p[] = "aabbccddeeff"; ReverseStr2(p, strlen(p)); printf("%s/n", p); return 0; } void ReverseStr(char* ptrSTR, int len) { char* ptrTemp = new char[len + 1]; strcpy(ptrTemp, ptrSTR); for(int i = 0; i < len; ++i) { ptrSTR[len - 1 - i] = ptrTemp[i]; } delete[] ptrTemp; } void ReverseStr2(char* ptrSTR, int len) { char* pBegin = ptrSTR; char* pEnd = ptrSTR + len - 1; while(pBegin < pEnd) { char ch = *pEnd; *(pEnd--) = *pBegin; *(pBegin++) = ch; } }