Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
C++:
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string s;
cin>>s;
int left=0;
int right=s.length()-1;
for(;left<right;left++,right--)
{
swap(s[left],s[right]);
}
cout<<s<<endl;
system("PAUSE");
return 0;
}
void swap(char a,char b)
{
char temp;
temp=a;
a=b;
b=a;
}