Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- string backspace(string tekst)
- {
- if(tekst == "")
- return tekst;
- string wynik = "";
- unsigned n = tekst.size() - 1;
- for(unsigned i = 0; i < n; ++i)
- wynik += tekst[i];
- return wynik;
- }
- char litera_ostatniego_slowa(vector<string> wektor)
- {
- string slowo = wektor[wektor.size() - 1];
- if(slowo == "")
- return '.';
- return slowo[slowo.size() - 1];
- }
- int main()
- {
- int n;
- cin>>n;
- int ile;
- string s;
- char h;
- vector<string> slowa;
- slowa.push_back("");
- for(int i = 0; i < n; ++i)
- {
- cin >> s;
- if(s == "dopisz")
- {
- cin >> h;
- s = slowa[i] + h;
- }
- else if(s == "backspace")
- s = backspace(slowa[i]);
- else
- {
- cin >> ile;
- s = slowa[i - ile];
- }
- slowa.push_back(s);
- cout << litera_ostatniego_slowa(slowa) << endl;
- }
- cout << slowa[slowa.size() - 1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment