[ create a new paste ] login | about

Link: http://codepad.org/3ePuawQW    [ raw code | output | fork ]

C++, pasted on Jan 9:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <algorithm>
#include <functional>
#include <iostream>

int main()
{
double arr[] = {-1,-2,-3,4,-5,-6,-7,8,-9,-10,11};
const size_t N = sizeof(arr) / sizeof(arr[0]);

double* first = std::find_if(arr, arr+N, std::bind2nd(std::greater<double>(), 0.0));
double* second = std::find_if(++first, arr+N, std::bind2nd(std::greater<double>(), 0.0));
std::cout << std::accumulate(first, second, 0.0) << std::endl;

return 0;
}


Output:
1
-18


Create a new paste based on this one


Comments: