递归实现字符串反转

void StringReverse(char* str,int Len)
{
	_ASSERT(str);
	char* p = str;
	char* q = str + Len - 1;
	if (p >= q)
		return;
	StringReverse(p + 1, Len - 2);
	*q = *p ^ *q;
	*p = *p ^ *q;
	*q = *p ^ *q;
}

你可能感兴趣的:(c++,算法)