代码拉取完成,页面将自动刷新
/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <iostream>
#include <vector>
#include <list>
#include <deque>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
void show(auto container,string sep=" ")
{
for(auto ele:container)
{
cout << ele << " ";
}
cout << endl;
}
int main_14()
{
srand((unsigned int)time(nullptr));
vector<int> v1;
list<int> l1;
deque<int> d1;
int random_num;
for (int i=0; i<10 ; ++i )
{
random_num=rand()%100;
v1.push_back(random_num);
}
show(v1);
cout <<"The number of elements in the vector is "<< v1.size() << endl;
cout << "The total number of elements that the vector can hold is "<<v1.capacity() << endl;
v1.resize(17);
show(v1);
cout <<"The number of elements in the vector is "<< v1.size() << endl;
cout << "The total number of elements that the vector can hold is "<<v1.capacity() << endl;
v1.resize(22,1);
show(v1);
cout <<"The number of elements in the vector is "<< v1.size() << endl;
cout << "The total number of elements that the vector can hold is "<<v1.capacity() << endl;
cout << "the size of the largest possible vector is "<<v1.max_size() << endl;
cout << "the size of the largest possible list is "<<l1.max_size() << endl;
cout << "the size of the largest possible deque is "<<d1.max_size() << endl;
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。