-
C ++연습] 튜토리얼 18-벡터와 벡터 함수-programminghelporg코딩Coding/C++_연습 2021. 12. 4. 14:45728x90
#include <vector> #include <iostream> using namespace std; int main() { vector<int> myVector; myVector.push_back(3); myVector.push_back(7); myVector.push_back(4); myVector.push_back(12); myVector.push_back(9); cout << "Vector: "; for (unsigned int i = 0; i < myVector.size(); i++) { cout << myVector[i] << " "; } myVector.insert(myVector.begin() + 3, 5); cout << "\nVector: "; for (unsigned int i = 0; i < myVector.size(); i++) { cout << myVector[i] << " "; } myVector.erase(myVector.begin() + 4); cout << "\nVector: "; for (unsigned int i = 0; i < myVector.size(); i++) { cout << myVector[i] << " "; } if (myVector.empty()) { cout << endl << "Is Empty!"; } else { cout << endl << "Is Not Empty"; } myVector.clear(); if (myVector.empty()) { cout << endl << "Is Empty!"; } else { cout << endl << "Is Not Empty"; } cout << endl; return 0; }
출처 :
https://www.youtube.com/watch?v=Cq1h1KPoGBU
반응형'코딩Coding > C++_연습' 카테고리의 다른 글
C++연습] STL-Vectors벡터 구현하기 (0) 2022.05.13 C++연습] vector for문 입력과 정렬 (0) 2022.01.25 C++연습)Vector of vectors(C++ Programming Tutorial-Engineer4Free (0) 2021.12.04 C++연습] Tutorial 19 - Vectors as Parameters (0) 2021.12.04 C++연습]Vector_push back & pop back (0) 2021.12.04 C++연습)How to make Unit converter in C++[kilo->mile+function+switch (0) 2021.12.03 C++연습] Unit Converter (0) 2021.12.03 C++연습] Programming Challenge 77개 도전 gogo~ (0) 2021.12.03