Trying to display the greatest and smallest difference by taking the previous entry and comparing it to the present. The smallest value is always zero. The answers also keep piling on for some reason.
you are adding sum_distance to distance[a], then putting the value back into sum_distance, which is fine. however, you don't initialise sum_distance when you declare it on line 25. So when you first come to do this addition the initial value of sum_distance is most likely full of rubbish.
in fact, when i try and step over line 28 in my debugger (vs2010), i get this:
Run-Time Check Failure #3 - The variable 'sum_distance' is being used without being initialized.
I didn't realize that I would get a garbage value if I didn't initialize but there's still the issue of the stacking results and and the smallest distance always being 0. It's a little weird but if you test the code you'll see that after a while of inputting values things begin to really pile up and loop over loops.
It's still able to be compiled but I added a tester to make sure that atleast two values are stored in the vector before executing the distance portion of the code if (a >=2) {body} Right above line 31.