Terrible Chandu

PROBLEM :

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     SAMPLE OUTPUT
2
ab                 ba
aba                aba

--------------------------------------------------------------------------------
SIMPLE C++ IMPLEMENTATION :
---------------------------------------------------------------------------------
#include <iostream>
using namespace std;
#include<string.h>

int main()
{
    int t,n,i ;
    char ch[30] ;
    cin>>t ;
    while(t--)
    {
    cin>>ch ;
    n=strlen(ch) ;
    for(i=n-1;i>=0;i--)
    cout<<ch[i] ;
   
    cout<<endl ;
    }
    return 0;
}

--------------------------------------------------------------------------------

Comments

Popular posts from this blog

Count ways to N'th Stair(Order does not matter)

Replace all ‘0’ with ‘5’ in an input Integer

Chocolate Distribution Problem

Remove characters from the first string which are present in the second string

Primality Test ( CodeChef Problem code: PRB01 )