"C++ 벡터 rotate()"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
==개요==
==개요==
;C++ 벡터 rotate()
;C++ 벡터 rotate()
;C++ 벡터 회전


<syntaxhighlight lang='cpp' run>
<syntaxhighlight lang='cpp' run>

2023년 9월 17일 (일) 20:46 판

1 개요

C++ 벡터 rotate()
C++ 벡터 회전
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main () {
  vector<int> v = {1, 2, 3, 4, 5};
  rotate(v.begin(), v.begin()+2, v.end());
  for(int x: v) cout << x << ' '; // 3 4 5 1 2
}

2 같이 보기

3 참고

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