求高手解决一道题
用递归的方法将一个字符串逆序存放怎么编写。(注:不要用指针)
程序代码:#include <stdio.h>
#include <iostream>
using namespace std;
void reverse(char string[], int len)
{
if (len <= 1) {
return;
}
char temp = string[0];
string[0] = string[len - 1];
string[len - 1] = temp;
reverse(&string[1], len - 2);
}
void main()
{
char StringTest[] = { "123456789abcdef" };
cout<<StringTest << endl;
reverse(StringTest, strlen(StringTest));
cout<<"reverse: "<< StringTest<<endl;
}








