CSCI 261 - Programming Concepts (C++)Summer 2018 - Lab 6A - Sort & SearchQuick Links: Canvas | CS @ Mines | Piazza | zyBooks |
|
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | |
This lab is due by Friday, June 08, 2018, 11:59 PM. Instructions
This lab will make Lab5F more useful. As before, have the user enter as
many numbers that they desire, using -1 to signify the end of input. The output at this point
should match the previous version:
Hey! Witness my first vector mojo!
Enter as many non-negative numbers as you'd like and I will tell you what they are. When you wish to be done, enter -1 to stop entering numbers. Your Number Is: 8 Your Number Is: 6 Your Number Is: 7 Your Number Is: 9 Your Number Is: 3 Your Number Is: 2 Your Number Is: 4 Your Number Is: -1 So awesome! You entered 7 numbers. The numbers are: 8 6 7 9 3 2 4 Have a nice day! The smallest number is: 2 The largest number is: 9 The first number is: 8 The last number is: 4 Gaze at my awesome.
Now for the extension Part 1. First print the values entered by the user in ascending order. Create a function called
vectorSort that
accepts the vector passed by reference as input and has no output.
Hey! Witness my first vector mojo!
Enter as many non-negative numbers as you'd like and I will tell you what they are. When you wish to be done, enter -1 to stop entering numbers. Your Number Is: 8 Your Number Is: 6 Your Number Is: 7 Your Number Is: 9 Your Number Is: 3 Your Number Is: 2 Your Number Is: 4 Your Number Is: -1 So awesome! You entered 7 numbers. The numbers are: 8 6 7 9 3 2 4 Have a nice day! The smallest number is: 2 The largest number is: 9 The first number is: 8 The last number is: 4 The numbers sorted are: 2 3 4 6 7 8 9 Gaze at my awesome.
Then, ask the user to enter a number to check if it was previously entered. The user should be able to enter as
many numbers as they wish, again using -1 to signify they are done. Use the following output as a guide
for the desired interaction. Create a function called
binarySearch that accepts two parameters as input,
the vector & target value, and returns a boolean as output. Be sure to use const appropriately.
Hey! Witness my first vector mojo!
Enter as many non-negative numbers as you'd like and I will tell you what they are. When you wish to be done, enter -1 to stop entering numbers. Your Number Is: 8 Your Number Is: 6 Your Number Is: 7 Your Number Is: 9 Your Number Is: 3 Your Number Is: 2 Your Number Is: 4 Your Number Is: -1 So awesome! You entered 7 numbers. The numbers are: 8 6 7 9 3 2 4 Have a nice day! The smallest number is: 2 The largest number is: 9 The first number is: 8 The last number is: 4 The numbers sorted are: 2 3 4 6 7 8 9 Enter a number to check if you previously entered it: 4 Yes you did! Enter a number to check if you previously entered it: 62 No, sorry you didn't. Enter a number to check if you previously entered it: -1 Gaze at my awesome. Functional Requirements
Lab SubmissionYou will submit your solution to this lab with the rest of Set6. Detailed instructions for doing this are posted in Assignment 6. This lab is due by Friday, June 08, 2018, 11:59 PM. | |
Last Updated: 05/30/18 11:25
|