#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
#include<cstdlib>
typedef double pixel_t;
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>
using namespace std;
using namespace cv;
int main()
{
int m = 2;
int n = 3;
//double * b = new double[n];//动态分配一个有n个数据的数组
double **b; //假定数组第一维长度为m, 第二维长度为n
b = new double *[m];//动态分配空间
for (int i = 0; i<m; i++)
{
b[i] = new double[n];
}
//double b[2][3];
size_t k = 2;
struct aa
{
double a[3];
};
vector<aa> f;
f.resize(k);
for (size_t i = 0; i < 3; i++)
{
f[0].a[i] = 1.5*i;
f[1].a[i] = 0.5*i;
}
b[0][0] = *f[0].a;
b[0][1] = *(f[0].a + 1);
b[0][2] = *(f[0].a + 2);
b[1][0] = *f[1].a;
b[1][1] = *(f[1].a + 1);
b[1][2] = *(f[1].a + 2);
cout << *f[0].a << endl;
cout << *(f[0].a + 1) << endl;
cout << *(f[0].a + 2) << endl;
cout << *f[1].a << endl;
cout << *(f[1].a + 1) << endl;
cout << *(f[1].a + 2) << endl;
cout << b[0][0] << endl;
cout << b[0][1] << endl;
cout << b[0][2] << endl;
cout << b[1][0] << endl;
cout << b[1][1] << endl;
cout << b[1][2] << endl;
vector<aa>(f).swap(f);
//释放动态分配的数组
for (int i = 0; i<m; i++)
{
delete[] b[i];
}
delete b;
cout << b[1][1] << endl;
cout << f.size() << endl;//输出当前容器内存储元素个数
cout << f.capacity() << endl; // 输出容器能存储数据的个数
system(\"pause\");
return 0;
}
继续阅读与本文标签相同的文章
专家:打造通用人工智能应知识与数据并重
-
功能超多还不占内存,果然浓缩的都是精华!
2026-05-18栏目: 教程
-
PC端如何不再窗口切换、实现沉浸式资料收集?
2026-05-18栏目: 教程
-
不蒸馒头争口气,哈弗H6、博越这些国产SUV让合资品牌不得不忌惮
2026-05-18栏目: 教程
-
中国移动向携号转网妥协,必须满足这一条件,网友:套路太深!
2026-05-18栏目: 教程
-
老板让我对比word文档差异,我用了2小时,同事1分钟就搞定了
2026-05-18栏目: 教程
