-
C++연습] Tutorial 19 - Vectors as Parameters코딩Coding/C++_연습 2021. 12. 4. 15:01728x90
#include <vector> #include <iostream> using namespace std; void fillVector(vector<int> &); void printVector(const vector<int> &); int main() { vector<int> myVector; fillVector(myVector); printVector(myVector); return 0; } void fillVector(vector<int> &newMyVector) { cout << "TYpe in list of numbers ( -1 top stop): "; int input; cin >> input; while (input != -1) { newMyVector.push_back(input); cin >> input; } cout << endl; } void printVector(const vector<int> &newMyVector) { cout << "Vector: "; for (unsigned int i = 0; i < newMyVector.size(); i++) { cout << newMyVector[i] << " "; } }
출처 :
https://www.youtube.com/watch?v=ReWNqNAhlkY
반응형'코딩Coding > C++_연습' 카테고리의 다른 글
C++❤계산기 만들기Calculator (0) 2022.11.28 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 ++연습] 튜토리얼 18-벡터와 벡터 함수-programminghelporg (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