![]() |
#2
shapoo2012-07-13 10:22
|
#include <iostream>
#include <string>
using namespace std;
int strlen(string& s){
int n=0;
while(s[n++]){}
return --n;
}
void revers(string& s,int n1,int n2){
if(n2-n1){
char temp=s[n1];
s[n1]=s[n2];
s[n2]=temp;
revers(s,++n1,--n2);
}
}
int main(){
string s="WangPeng";
revers(s,0,strlen(s)-1);
for(int i=0;i<strlen(s);i++) cout<<s[i];
return 0;
}
编译通过,运行不成功,请教问题出在哪?