please use vector

This commit is contained in:
e2hang
2025-07-21 18:12:24 +08:00
parent a18c6ba5d4
commit 63b4beadae
3 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector<int> a;
vector<int> b(3,100);//b = {100, 100, 100}
vector<int> c(b.begin(),b.end());
vector<int> d(c);
for(/*vector<int>::iterator*/ auto ti = b.begin(); ti != b.end(); ti++){
cout << *ti << " ";
}
cout << endl;
b.push_back(300);
b.push_back(500);
cout << b.size() << " " << b.capacity() << endl;
b.resize(10);
cout << b.size() << " " << b.capacity() << endl;
return 0;
}