Given a String of length S, reverse the whole string without reversing the individual words in it. Words are separated by dots.
Input: The first line contains T denoting the number of testcases. T testcases follow. Each case contains a string S containing characters.
Output: For each test case, in a new line, output a single line containing the reversed String.
Constraints: 1 <= T <= 100 1 <= |S| <= 2000
Example: Input:
i.like.this.program.very.much
Output: much.very.program.this.like.i
#include <bits/stdc++.h>
using namespace std;
int main() {
//code
int t;cin>>t;
while(t--) {
string s;
cin>>s;
stack<string> st;
int siz = s.size();
char c[siz];
for(int i =0;i<siz;i++) {
c[i] = s[i];
}
char *token = strtok(c,".");
while (token != NULL)
{
st.push(token);
st.push(".");
token = strtok(NULL, ".");
}
st.pop();
while(!st.empty()) {
cout<<st.top();
st.pop();
}
cout<<"\n";
}
return 0;
}