使用STL的C ++阵列产品
这是一个C++程序的示例,用于查找数组产品。
算法
Begin Initialize the values of array. Call used defined function accumulate to return the product of array. Print the solution. End.
范例程式码
#include <iostream>
#include <numeric>
using namespace std;
int ProductOfArray(int p[], int n) {
return accumulate(p, p + n, 1, multiplies<int>());
}
int main() {
int m[] = {6,7 };
int n = sizeof(m) / sizeof(m[0]);
cout <<"数组的乘积为:" <<ProductOfArray(m, n);
}输出结果
数组的乘积为:42
热门推荐
10 圣诞祝福语简短文字
11 红颜生日祝福语简短独特
12 带清的简短祝福语
13 简短的小孩春节祝福语
14 公司春节祝福语和简短
15 新年给妹妹祝福语简短
16 叔叔生日祝福语简短励志
17 家公生日的祝福语简短
18 简短的出行工作祝福语