elements of the array: 1,2,4,10,12,14
array_size = 6
I want to find the max width between each numbers. I mean, the width between 1 and 2 is 2-1 = 1. In this case, the max is 10-4 = 6. This part is OK.
1 2 3 4 5 6 7
vector<double> mynumbers;
for (int i = 1; i < array_size ; ++i) {
constdouble width = p[i] - p[i-1]; // calculate the width between each numbers.
mynumbers.push_back(witdh);
}
constdouble maxwidth = *max_element(mynumbers.begin(), mynumbers.end()); // find the max width.
This part gives me the max width.
In addition, I want to find the center of max width by (10+4) / 2 = 7. So, I would like to keep two values, the width and center of width.
the width is : 10-4 = 6
center of the width: (10+4)/2 = 7