fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. string s;
  4. int main() {
  5. int ile=0;
  6. getline(cin,s);
  7. s=" "+s;
  8. for(int i=s.size()-1; i>=0; i--)
  9. {
  10. if(s[i]!=' ')
  11. {
  12. ile++;
  13. }
  14. if(s[i]==' ')
  15. {
  16. if(i!=0)
  17. {
  18. for(int j=i+1; j<i+ile+1; j++)
  19. {
  20. cout<<s[j];
  21. }
  22. cout<<" ";
  23. ile=0;
  24. }
  25. if(i==0)
  26. {
  27. for(int j=i+1; j<i+ile+1; j++)
  28. {
  29. cout<<s[j];
  30. }
  31. ile=0;
  32. }
  33. }
  34. }
  35. cout<<".";
  36. return 0;
  37. }
Success #stdin #stdout 0s 5460KB
stdin
Ala ma kota rybki oraz psa
stdout
psa oraz rybki kota ma Ala.