C++ 벡터 insert()

Jmnote (토론 | 기여)님의 2023년 10월 1일 (일) 14:15 판 (새 문서: ==개요== ;C++ 벡터 insert() <syntaxhighlight lang='cpp' run> #include <iostream> #include <vector> using namespace std; int main () { vector<int> v (3,100); vector<int>::iter...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

C++ 벡터 insert()
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
  vector<int> v (3,100);
  vector<int>::iterator it;

  it = v.begin();
  it = v.insert ( it , 200 );

  v.insert (it,2,300);

  it = v.begin();

  vector<int> w (2,400);
  v.insert (it+2,w.begin(),w.end());

  int arr [] = { 501,502,503 };
  v.insert (v.begin(), arr, arr+3);

  for (it=v.begin(); it<v.end(); it++) {
    cout << *it << ' ';
  }
}

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}