Skip to content

Commit

Permalink
2024-03-29 에디터
Browse files Browse the repository at this point in the history
  • Loading branch information
oesnuj committed Mar 29, 2024
1 parent 8bafb48 commit 18493c7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions oesnuj/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
| 차시 | 날짜 | 문제유형 | 링크 | 풀이 |
|:----:|:---------:|:----:|:-----:|:----:|
| 1차시 | 2024.03.26 | 스택 | [후위표기식2](https://www.acmicpc.net/problem/1935) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/4) |
| 2차시 | 2024.03.29 | 연결리스트 | [에디터](https://www.acmicpc.net/problem/1406) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/8) |
---
50 changes: 50 additions & 0 deletions oesnuj/연결리스트/1406.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <iostream>
#include <list>
using namespace std;
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
list <char> li; //양방향 연결리스트 선언
string str;
cin >> str;
for (auto c : str) //한 문자씩 연결리스트에 넣기
li.push_back(c);

list<char>::iterator it = li.end();
int t;
cin >> t;
while(t--)
{
char input;
cin >> input;
if (input == 'L')
{
if (it != li.begin())
it--;
}
else if (input == 'D')
{
if (it != li.end())
it++;
}
else if (input == 'B')
{
if (it != li.begin())
{
it--;
it = li.erase(it);
}
}
else if (input == 'P')
{
char insertChar;
cin >> insertChar;
it = li.insert(it, insertChar);
it++;
}
}

for (auto c : li)
cout << c;
return 0;
}

0 comments on commit 18493c7

Please sign in to comment.