Skip to content

Instantly share code, notes, and snippets.

@aryelleification
Created September 25, 2014 15:48
Show Gist options
  • Save aryelleification/d3df4a287a92e8bca2d0 to your computer and use it in GitHub Desktop.
Save aryelleification/d3df4a287a92e8bca2d0 to your computer and use it in GitHub Desktop.
Write a C++ program that
Accepts a file name from the user
Reads the numbers in that file and stores them in a vector
Checks the numbers in the vector to ensure that they are sorted
Accepts a file name from the user
Reads pairs of numbers, lower bound and upper bound, from that file one pair at a time
For each pair of bounds
**Calculates the between bounds count: the number of doubles in the vector that lie between the bounds
Reports the bounds and the between bounds count
Reports the pair of bounds with the largest between bounds count
** Use two functions to calculate the between bounds count.
findGT uses the binary search process to find the first item in a sorted vector that is greater than a target value
findGE uses the binary search process to find the first item in a sorted vector that is greater than or equal to a target value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment