使用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 寒露祝福语毕业寄语简短