Monday, 15 February 2016

Terrible Chandu

Chandu is a bad student. Once his teacher asked him to print the reverse of a given string. He took three hours to solve it. The teacher got agitated at Chandu and asked you the same question. Can you solve it?
Input:
The first line contains an integer T, denoting the number of test cases.
Each test case contains a string S, comprising of only lower case letters.
Output:
For each test case, print the reverse of the string S.
Constraints:
1 <= T <= 10
1 <= |S| <= 30
Sample Input

2
ab
aba
Sample Output
ba
aba


#include<iostream>
#include<string>

#include<algorithm>
using namespace std;
string reverse_(string s);
int main()
{
 int T;
 cin>>T;
string *S = new string[T];
 for(int i=0;i<T;i++)
 {
  cin>>S[i];
 }
 cout<<"\n\n";
 for(int i=0;i<T;i++)
 {
  std::reverse(std::begin(S[i]), std::end(S[i]));
  std::cout<<S[i]<<"\n";
 }
}