chào mọi người ạ, dạo gần đây em có học về vector,yêu cầu là em thực hiện việc ghép nối 2 vector a,và b thì ý tưởng của e là sẽ dùng push_back để gán phần tử của vector b vào vector a, nhưng ghi in ra màn hình thì n lại thành thế này ạ
đây là code của e ạ, ai biết thì chỉ cho e vowisi :"((((((((
#include<iostream>
#include<vector>
using namespace std;
void makeArray(vector<int>&a, int arrayold[], int n) {
int i = 0;
a.resize(0);
while (i < n) {
a.push_back(arrayold[i]);
}
}
void arrayOutput(vector<int>&a, ostream& outDev) {
for (int i = 0; i < a.size(); i++) {
outDev << a[i] << " ";
}
outDev << endl;
}
void matchArray1(vector<int>&a, vector<int> &b) {
int size2 = b.size();
while (int i = 0 < size2) {
a.push_back(b[i]);
}
}
void main() {
int x[] = { 0,1,2,3,4,5,6,7,8,9 };
int b2[] = { 9,1,5 };
int n2 = sizeof(b2) / sizeof(b2[0]);
int n = sizeof(x) / sizeof(x[0]);
vector<int> a, b, c;
makeArray(a, x, n);
makeArray(b, b2, n2);
matchArray1(a, b);
arrayOutput(a, cout);
}