SW Expert Academy
(SWEA c++)1228. [S/W 문제해결 기본] 8일차 - 암호문1
naeunchan
2020. 10. 13. 10:25
728x90
반응형
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
list를 이용하여 문제 해결.
list를 처음 써봤는데 많이 유용한 STL인 듯 하다.
[C++] list container 정리 및 사용법
안녕하세요, BlockDMask 입니다. 오늘은 STL의 sequence container 의 vector, deque, list중 세번째 인 list에 대해서 알아보겠습니다. 날이 정말 덥군요. 저는 시원한 카페에 앉아서 포스팅 해보도록하겠습니.
blockdmask.tistory.com
list 관련해서 참고한 블로그다.
#include <iostream>
#include <list>
using namespace std;
int main(void)
{
for(int t = 1; t <= 10; t++)
{
int n, x, y, s;
char c;
list<int> lt;
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> x;
lt.push_back(x);
}
cin >> n;
for(int i = 0; i < n; i++)
{
list<int> tmp;
auto itr = lt.begin();
cin >> c >> x >> y;
for(int j = 0; j < x; j++)
itr++;
for(int j = 0; j < y; j++)
{
cin >> s;
tmp.push_back(s);
}
lt.splice(itr, tmp);
}
cout << "#" << t << " ";
auto itr = lt.begin();
for(int i = 0; i < 10; i++, itr++)
cout << *itr << " ";
cout << endl;
}
return 0;
}
728x90
반응형