Skip to content

Commit

Permalink
Merge pull request #8 from AlgoLeadMe/2-oesnuj
Browse files Browse the repository at this point in the history
2-oesnuj
  • Loading branch information
oesnuj committed Apr 2, 2024
2 parents ee472a0 + 6034aae commit 570524d
Show file tree
Hide file tree
Showing 2 changed files with 50 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) |
---
49 changes: 49 additions & 0 deletions oesnuj/연결리스트/1406.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#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;
li.insert(it, insertChar);
}
}

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

0 comments on commit 570524d

Please sign in to comment.