Open devLupin opened 1 year ago
rotate
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> v = { 10, 40, 50, 30, 20 }; cout << "vector : "; for (int i : v) cout << i << " "; cout << "\n================================\n"; rotate(v.begin(), v.begin() + 1, v.end()); cout << "1칸씩 왼쪽 이동 : "; for (int i : v) cout << i << " "; cout << "\n================================\n"; rotate(v.begin(), v.end() - 1 , v.end()); cout << "1칸씩 오른쪽 이동 : "; for (int i : v) cout << i << " "; cout << "\n================================\n"; return 0; }
관련 문제 및 내가 작성한 코드
rotate
usage