可以在此基础上无限次叠加拼接次数。
#include<iostream>
int main( ){
int n = 9;
int m = 3;
int r = 4;
double array[9] = {3,3,3,3,3,5,6,7,9};
double a[3] = {3,5,7};
double b[4] = {0,0,0,1};
int aa[16] = {0};
int i, j, k;
for (i = 0; i < n; i++)
aa[i] = array[i];
// std::cout << i << std::endl;
for (j = 0; j < m; j++,i++)
aa[i] = a[j];
// std::cout << i << " " << j << std::endl;
for (k = 0; k < r; j++,i++,k++ )
aa[i] = b[k];
// std::cout << k << std::endl;
for (i = 0; i<m+n+r; i++)
std::cout << aa[i] << " ";
// cv::Mat mean = (cv::Mat_<double>(4, 4) << aa[i]);
// std::cout << "mean=" << mean << std::endl;
return 0;
}
另一种方法:
#include<iostream>
#include <stdlib.h>
#include <vector>
using namespace std;
//定义指针函数
int *copy(int array[], int a[], int aa[], int n, int m);
int main(){
int size = 4;
int a2[4] = {3,3,3,3};
int a1[4] = {3,5,7,8};
int a3[9] = {0};
int *p;
p = copy(a1, a2, a3, 4,4);
cout << p[0] << " " << p[0] << " " << p[1] << " " << p[2] << " " << p[3] << " " << p[4] << " " << p[4] << " " << p[6] << " " << p[7] << " " << p[8] << " " << p[9] << " " << p[10] <<endl;
return 0;
}
int *copy(int array[], int a[], int aa[], int n, int m)
{
int i, j;
for (i = 0; i < n; i++)
aa[i] = array[i];
for (j = 0; j < m; j++,i++)
aa[i] = a[j];
for (i = 0; i<m+n; i++)
//printf("%d,", aa[i]);
return aa;
}
网友评论