Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <sstream>
- using namespace std;
- class Word
- {
- private:
- public:
- vector<string> vec;
- int num;
- //funkiq za popylvane danni
- void setInput()
- {
- string word, line;
- getline(cin, line);
- istringstream input(line);
- while (input >> word)
- {
- vec.push_back(word);
- }
- }
- //vyvejdane number
- void setNumber()
- {
- cin >> this->num;
- }
- string getSentence()
- {
- ostringstream ostr;
- ostr << vec[vec.size() - num]<<endl;
- ostr << vec[vec.size() - 1] << endl;
- for (int i = 0; i < vec.size()-num; i++)
- {
- ostr << vec[i]<<endl;
- }
- return ostr.str();
- };
- };
- int main()
- {
- Word words;
- words.setInput();
- words.setNumber();
- cout<<words.getSentence();
- }
Add Comment
Please, Sign In to add comment