c++ standard library <numeric> accumulate demo
2015-02-01 19:14
519 查看
#include <iostream> #include <vector> #include <numeric> using namespace std; int main() { int arr[] = {1, 2, 5, 10}; size_t array_size = sizeof(arr) / sizeof(arr[0]); vector<int> ivec(arr, arr + array_size); int sum = accumulate(ivec.begin(), ivec.end(), 0); cout << sum << endl; return 0; }
相关文章推荐
- c++ standard library 学习笔记-auto_ptr<T> 注意事项
- C/C++ standard library -- <cstring>(string.h)
- C Standard Library: 7 Variable Argument Lists: <stdarg.h>
- STL algorithm accumulate vector<string> demo
- C Standard Library: 8 Non-local Jumps: <setjmp.h>
- standard c library <string.h>
- c++ standard library fill_n demo
- C Standard Library: 1 Input and Output: <stdio.h>
- C Standard Library: 6 Diagnostics: <assert.h>
- C Standard Library: 9 Signals: <signal.h>
- C Standard Library: 2 Character Class Tests: <ctype.h>
- c++ standard library algorithm count demo
- c++ STL ostream_iterator<> demo
- C Standard Library:4 Mathematical Functions: <math.h>
- c++ STL istream_iterator<> demo
- C Standard Library: 10 Date and Time Functions: <time.h>
- C++库常用函数一览(<string><cctype><algorithm><cmath><cstdlib><iomanip><numeric>)
- C++库常用函数一览(<string><cctype><algorithm><cmath><cstdlib><iomanip><numeric>)
- C Standard Library: 3 String Functions: <string.h>
- C Standard Library:5 Utility Functions: <stdlib.h>