标准模板7

#include<iostream>
#include<numeric>
using namespace std;
class MultClass{
public:
int operator() (int x,int y) const{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,MultClass())<<endl;
return 0;
}

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