Advertisement
naskedvi

S3 - zad.21

Mar 30th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::cout<<"Unesite recenicu:" << std::endl;
  7. std::string recenica;
  8. std::getline(std::cin,recenica);
  9.  
  10. std::string rijec="";
  11. bool nasao = false;
  12.  
  13. for (int i=recenica.size()-1;i>=0; i--)
  14. {
  15. if(recenica[i]==' ')
  16. {
  17. if (nasao)
  18. {
  19. std::cout<<"Posljednja rijec je: ";
  20. for (int j=rijec.size()-1;j>=0; j--)
  21. std::cout<<rijec[j];
  22. break;
  23. }
  24.  
  25. }
  26.  
  27. else
  28. {
  29. nasao = true;
  30. rijec += recenica[i];
  31. }
  32. }
  33.  
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement