Quiz: Vectors
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v;
for(int i = 1; i <= 17; ++i)
v.push_back(i);
for(int i = 1; i <= 12; ++i)
v.pop_back();
for(int i = 1; i <= 3; ++i)
v.push_back(i);
cout << v.size() << ' ' << v.capacity() << '\n';
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v;
for(int i = 1; i <= 10; ++i)
v.push_back(i);
while(v.size() > 5) {
v[v.back()%5] += v.back();
v.pop_back();
}
for(int x : v)
cout << x << ' ';
return 0;
}