#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;
#define siz 100
char as[siz];
void rev(int i, int j){
if(i>j) return;
else{
swap(as[i],as[j]);
rev(i+1,j-1);
}
}
int main()
{
while(cin>>as){
int len=strlen(as)-1;
rev(0,len);
cout<<as<<endl;
}
return 0;
}
Sunday, November 4, 2012
String Reverse Using Recursion
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment