使用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 上级生日祝福语 简短独特