Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- typedef std::string::iterator iter;
- typedef std::string::const_iterator citer;
- iter function(citer a, citer b, iter wyjscie)
- {
- citer aplus = a + 1;
- while (aplus != b)
- {
- *wyjscie = *aplus;
- *(wyjscie + 1) = *a;
- wyjscie += 2;
- ++a;
- ++aplus;
- if (aplus == b)
- {
- break;
- }
- ++a;
- ++aplus;
- }
- int rozm = b - a;
- if (rozm % 2 == 1)
- {
- *wyjscie++ = *a;
- }
- return wyjscie;
- }
- int main()
- {
- std::string in = "peppermint 1001 bubbles balloon gum", out(100, '*');
- auto e = function(in.cbegin(), in.cend(), out.begin());
- int n = e - out.begin();
- std::string s = out.substr(0, n);
- bool b = (s == "epppreimtn1 00 1ubbbel sablloo nugm");
- std::cout << std::boolalpha << b << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement