vector<vector<int>>

/************************************************************************ 
    Copyright (C) 2015-2020. 
    File name:    
    Author:      Greenapple 
    QQ:          361348440 
    EMail:       361348440@qq.com 
    Version:     V1.0 
    Date:        2015/3/15
    Description: STL vector usage
    Others:      无 
    Modification:  1.vector<vector<int>>  2.维数达到3维
    1. 2015/3/15 : 第一次编写完成。 
************************************************************************/ 

#include <iostream>
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace std;

const int TOTAL_NUM=4;
const int DIM=3;

vector<vector<int>>vec_pt;

void readData3Dims()
{
	freopen("input_3.txt","r",stdin);
	for(int i=0;i<TOTAL_NUM;++i)
	{
		//int *temp=new int [DIM];
		//int temp[DIM];
		vector<int> vec_temp;
		for(int j=0;j<DIM;++j)
		{
			int tmp;
			cin>>tmp;
			vec_temp.push_back(tmp);
			//cout<<vec_temp[j]<<" ";
		}
		//cout<<endl;
		vec_pt.push_back(vec_temp);
	}
	fclose(stdin);
}

int main()
{
	readData3Dims();
	int vec_size=static_cast<int>(vec_pt.size());
	cv::Mat_<float> vec(vec_size,DIM);
	vec.setTo(0);
	for(int y=0;y<vec.rows;++y)
	{

		for(int x=0;x<vec.cols;++x)
		{
			vector<int> vec_tmp;
			vec_tmp=vec_pt[y];
			vec(y,x)=vec_tmp[x];
		}
	}
	//show vec;
	for(int y=0;y<vec.rows;++y)
	{
		for(int x=0;x<vec.cols;++x)
		{
			cout<<vec(y,x)<<" ";
		}
		cout<<endl;
	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值