标准模板6

#include<iostream>
#include<numeric>
using namespace std;
int mult(int x,int y) {return x*y;};
int main()
{
int a[]={1,2,3,4,5};
const int N=sizeof(a)/sizeof(int);
cout<<"The result by multipling all elements in a is "<<accumulate(a,a+N,1,mult)<<endl;
return 0;
}

posted @ 2023-05-11 13:19  不会JAVA的小袁  阅读(8)  评论(0编辑  收藏  举报