Text Reverse
#include<iostream>
using namespace std;
#include<string>
int main()
{
string a;
char temp;
int j,i,x = 0 , y = 0 ;
int n,k;
cin>>n;
a="\n";
getline(cin,a);
for(k = 0 ; k < n ; k++)
{
getline(cin,a);
for(j = 0 ; j < a.size() ; j++)
{
if(a[j] == ' ')
{
x = j;
for(i = y ; i < ( x + y )/2 ; i++)
{
temp = a[i];
a[i] = a[x-1-(i-y)];
a[x-1-(i-y)] = temp;
}
y = j+1;
}
}
for(i = y ; i < ( a.size() + y )/2 ; i++)
{
temp = a[i];
a[i] = a[a.size()-1-(i-y)];
a[a.size()-1-(i-y)] = temp;
}
x = 0;
y = 0;
cout<<a<<endl;
}
return 0;
}