C++ vector 实例二
2024-10-06 20:55:31
// constructing vectors
#include <iostream>
#include <vector> int main ()
{
// constructors used in the same order as described above:
std::vector<int> first; // empty vector of ints
std::vector<int> second (4, 100); // four ints with value 100
std::vector<int> third (second.begin(), second.end()); // iterating through second
std::vector<int> fourth (third); // a copy of third std::cout << "The contents of second are:";
for (std::vector<int>::iterator it = second.begin(); it != second.end(); ++it)
{
std::cout << ' ' << *it;
}
std::cout << '\n'; // the iterator constructor can also be used to construct from arrays:
int myints[] = {16, 2, 77, 29};
std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) ); std::cout << "The contents of fifth are:";
for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it)
{
std::cout << ' ' << *it;
}
std::cout << '\n'; return 0;
}
最新文章
- C# 使用IComparer自定义List类的排序方案
- Ubuntu 16.04中安装Chromium浏览器
- 注解@PostConstruct与@PreDestroy讲解及实例
- Spring 通过FactoryBean配置Bean
- Unhandled Error in Silverlight Application “Syncfusion.Silverlight.Olap.Gauge.OlapGauge”的类型初始值设定项引发异常
- [iOS基础控件 - 7.0] UIWebView
- 在Tomcat中配置基于springside的项目
- asp.net将数据库中的数据赋给DropDownList
- DC综合环境的一些概念
- linux动态库加载的秘密
- To the Max(矩阵压缩)
- Spring Data Rest 支持Put请求
- SQL数据库文件修复/用友/金蝶/管家婆/速达/思讯数据库恢复 硬盘恢复
- 解决xcode10打包报错:That command depends on command in Target ‘xxx’:scrpit phase";[CP] Copy Pods Resources";
- How to install Hadoop Cluster
- lvm讲解/磁盘故障小案例
- IPC通信:Posix消息队列
- java &; maven pom
- day01作业
- Objective-C-类(static)方法、实例方法、overwrite(覆写)、属性(property)复习