-
1406) 에디터 c++백준코딩일기 2020. 11. 5. 12:55
문제 ) www.acmicpc.net/problem/1406
풀이 )
코드 )
#include <iostream> #include <string> #include <list> using namespace std; int main(){ int n; string s; cin >> s >> n; list<char> l(s.begin(),s.end()); auto now = l.end(); while(n--){ char tmp; cin >> tmp; if(tmp == 'L'){ if(now != l.begin()){ now--; } } else if(tmp == 'D'){ if(now != l.end()){ now++; } } else if(tmp == 'B'){ if(now != l.begin()){ now = l.erase(--now); } } else if(tmp == 'P'){ char c; cin >> c; l.insert(now, c); } } for (auto it = l.begin(); it != l.end(); it++) { cout << *it; } return 0; }
'백준코딩일기' 카테고리의 다른 글
1158) 요세푸스 문제 (0) 2020.11.05 5397) 키로거 c++ (0) 2020.11.05 5430) AC c++ (0) 2020.11.05 1021) 회전하는 큐 c++ (0) 2020.11.04 10866) 덱 c++ (0) 2020.11.04