fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <iostream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int t;
  11. cin>>t;
  12. while(t--)
  13. {
  14. string s;
  15. cin>>s;
  16. int p=0,j=0;
  17. int k=s.length()-1;
  18. int e =s.length()-1;
  19. while(k>0)
  20. {
  21. while(s[k]!='.')
  22. k--;
  23. p=k+1;
  24. string res= s.substr(p,e);
  25. cout<<res<<'.';
  26. e=k-1;
  27. k=k-1;
  28. }
  29. while(s[j]!='.')
  30. {
  31. j++;
  32. }
  33. cout<<s.substr(0,j-1);
  34. cout<<endl;
  35. }
  36. return 0;
  37.  
  38. }
Success #stdin #stdout 0s 15240KB
stdin
1
i.love.you
stdout
you.love..