Skip to content

Commit

Permalink
5397번 - 키로거
Browse files Browse the repository at this point in the history
  • Loading branch information
MGPOCKY committed Jul 11, 2024
1 parent 197eae2 commit d1784af
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions 201902654/5397.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <string>
#include <list>
#include <iostream>

using namespace std;

int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int test_case;
cin >> test_case;
for (int i=0;i<test_case;++i){
string input;
list<char> L;
auto cursor = L.end();
cin >> input;

for (char ch : input) {
if (ch == '<') {
if (cursor != L.begin()) {
cursor--;
}
} else if (ch == '>') {
if (cursor != L.end()) {
cursor++;
}
} else if (ch == '-') {
if (cursor != L.begin()) {
cursor--;
cursor = L.erase(cursor);
}
} else {
L.insert(cursor, ch);
}
}

for (char ch : L) {
cout << ch;
}
cout << '\n';
}

return 0;
}

0 comments on commit d1784af

Please sign in to comment.