使用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
热门推荐
3 孙媳妇祝福语简短
10 新娘对伴娘祝福语简短
11 收到公公生日祝福语简短
12 迎新祝福语简短20字
13 白羊生日祝福语 简短独特
14 结婚祝福语亲姐姐简短
15 对学姐的简短祝福语
16 新年送老师简短祝福语
17 幼儿老师过年简短祝福语
18 老师节祝福语的简短