Skip to content

Instantly share code, notes, and snippets.

@pillows
Created April 19, 2017 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pillows/d99bddda0cbae9b7d860125a1442b0c5 to your computer and use it in GitHub Desktop.
Save pillows/d99bddda0cbae9b7d860125a1442b0c5 to your computer and use it in GitHub Desktop.

(25%) Suppose input data about [simplified] New York street lights has the following fields in order: avenue, street, timeR, timeG, timeY. All the fields are integers, and the time fields indicate the number of seconds the light stays each color. Write a code fragment that reads the data from keyboard input (no prompting needed), and outputs the 2 largest green light delays on avenue a. You may assume:

  • The avenua a has been initialized to some legal avenue
  • There are no errors in input (though the input will contain data for all avenues)
  • The times are distinct (i.e., no two times are the same)
  • The cin returns false when there is no more data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment