Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- #include <string>
- using namespace std;
- struct el {
- string a;
- el *p = NULL;
- }
- int main() {
- string line;
- getline(cin, line);
- stringstream input(line);
- el *first = new el;
- el *cur = first;
- el *k = NULL;
- el *t = NULL;
- while (input >> cur->a) {
- cur->p = new el;
- if (cur->a[0] == 'k' && !k) k = cur;
- if (cur->a[0] == 't' && !t) t = cur;
- cur = cur->p;
- }
- if (k && t) swap(*k, *t);
- for (; first->next; first = first->p) {
- cout << first->a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement