Skip to content

Commit

Permalink
Update 1406.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
oesnuj authored Apr 2, 2024
1 parent daf1946 commit ec065b7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions oesnuj/연결리스트/1406.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main()
for (auto c : str) //한 문자씩 연결리스트에 넣기
li.push_back(c);

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

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

0 comments on commit ec065b7

Please sign in to comment.