使用vector创建一个二维数组(二)
来源:互联网 发布:php object to array 编辑:程序博客网 时间:2024/05/16 03:27
创建一个m*n的整型二维数组:
vector<int> temp(n); //先创建一个含有n个元素的一维数组 vector<vector<int>> matrix(m,temp); //再根据穿件m个含有n个元素的一维数组构成的二维数组
测试代码:
#include<iostream>#include<vector>using namespace std;int main() { //创建一个4*5的二维数组 vector<int> temp(5); vector<vector<int> > matrix(4,temp); cout<<"row:"<<matrix.size()<<endl; cout<<"column:"<<matrix[0].size()<<endl; cout<<"["<<endl; for(int i=0;i<matrix.size();++i) { cout<<"["<<" "; for(int j=0;j<matrix[0].size();++j) { cout<<matrix[i][j]<<" "; } cout<<"]"<<endl; } cout<<"]"<<endl; return 0;}
0 0
- 使用vector创建一个二维数组(二)
- 使用vector创建一个二维数组(一)
- 使用vector容器创建二维数组
- 使用STL:vector创建二维数组
- vector二维数组使用
- 动态创建二维vector数组
- 动态创建二维vector数组
- 用vector创建二维数组
- 动态创建二维vector数组
- 动态创建二维vector数组
- 动态创建二维vector数组
- 动态创建二维vector数组
- 动态创建二维vector数组
- 动态创建二维vector数组
- vector创建的二维数组
- 创建一个二维数组
- 使用Vector实现二维数组
- 使用Vector实现二维数组
- iOS安全系列之二:HTTPS进阶
- JavaScript的三种消息框alert,confirm,prompt
- PAT1054
- 调用AsyncTask的excute方法不能立即执行程序的原因分析及改善方案
- Android6.0的phone应用源码分析(6)——RIL层框架分析
- 使用vector创建一个二维数组(二)
- socket的心跳包机制
- JavaWeb:后台判断是手机登陆还是Pc登陆
- [面试/网络] TCP/IP:数据链路层、IP协议以及IP协议相关技术
- python implement queue
- 2016年3月份工作和学习计划
- (175)红黑树及其相关操作
- linux配置SSH免密码登陆方法
- Eclipse运行struts2项目报错:java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.Strut