-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathcpp11_11_array.cpp
More file actions
39 lines (35 loc) · 816 Bytes
/
cpp11_11_array.cpp
File metadata and controls
39 lines (35 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*************************************************************************
> File Name: cpp11_11_array.cpp
> Author: DragonFive
> Mail: [email protected]
> Created Time: 2016年07月24日 星期日 19时02分56秒
************************************************************************/
#include<iostream>
#include<algorithm>
#include<array>
using namespace std;
void print(auto list)
{
for(auto item:list)
{
cout<<item<<" ";
}
cout<<endl;
}
template<typename C> typename C::value_type sum(const C& list)
{
//auto sumResult=NULL;
//for(auto item:list)
//{
// sumResult+=item;
//}
//return sumResult;
return accumulate(list.begin(),list.end(),0);
}
int main()
{
array<int,6> ar={1,2,3};
print(ar);
cout<<sum(ar)<<endl;
return 0;
}