1 Star 1 Fork 0

AlbertDarren / STL

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sequenceContainerOperations4.cpp 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
AlbertDarren 提交于 2022-04-03 00:55 . first commit
/**
* @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;
}
C++
1
https://gitee.com/AlbertDarren_admin/stl.git
git@gitee.com:AlbertDarren_admin/stl.git
AlbertDarren_admin
stl
STL
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891