Guest User

sent

a guest
Jun 3rd, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <sstream>
  6.  
  7. using namespace std;
  8. class Word
  9. {
  10. private:
  11. public:
  12.  
  13. vector<string> vec;
  14. int num;
  15.  
  16.  
  17. //funkiq za popylvane danni
  18. void setInput()
  19. {
  20. string word, line;
  21. getline(cin, line);
  22. istringstream input(line);
  23.  
  24. while (input >> word)
  25. {
  26. vec.push_back(word);
  27. }
  28. }
  29.  
  30. //vyvejdane number
  31. void setNumber()
  32. {
  33. cin >> this->num;
  34. }
  35.  
  36. string getSentence()
  37. {
  38. ostringstream ostr;
  39. ostr << vec[vec.size() - num]<<endl;
  40. ostr << vec[vec.size() - 1] << endl;
  41. for (int i = 0; i < vec.size()-num; i++)
  42. {
  43. ostr << vec[i]<<endl;
  44. }
  45.  
  46.  
  47.  
  48. return ostr.str();
  49. };
  50.  
  51.  
  52.  
  53. };
  54.  
  55.  
  56.  
  57. int main()
  58. {
  59. Word words;
  60. words.setInput();
  61. words.setNumber();
  62. cout<<words.getSentence();
  63.  
  64. }
Add Comment
Please, Sign In to add comment