C+实现一组数据循环和运算,输出结果累加输出到一个指定的数组

#include <iostream>
#include <stdio.h>
#include <sys/timeb.h>
#include <vector>
using namespace std;
long long getSystemTime() {
struct timeb t;
ftime(&t);
return 1000 * t.time + t.millitm;
}
/*
namespace cv
{
using std::vector;
}
*/

int N =(16000*40*128)/8;
float input [8][N];
float output[N] = {0};
int main() {
int i , j;
for(i =0 ;i < 8; ++i) {
for (size_t j =0; j < N; ++j){
input[i][j] = i + j;
}
}


long long start=getSystemTime();


for (size_t i = 0; i < N; ++i) {
for ( j = 0; j < 8; ++j) {
output[i] += input[j][i];
}
}
//cout<<output<<endl;
//cout<<" 累加计算:"<<sum<<endl;
long long end=getSystemTime();

printf("time: %lld ms ", end-start);
return 0;
}

原文地址:https://www.cnblogs.com/dpf-learn/p/13137968.html