C++ 벡터 rotate()

Jmnote (토론 | 기여)님의 2023년 9월 17일 (일) 20:48 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

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 }}