A user is going to enter numbers one at a time, entering 'q' when finished. Put the numbers in a list, sort it in numerical order, and print out the list. Then print out the middle element of the list. (If the list has an even number of elements, print the one just after the middle.) Remember that a list 1st of numbers can be sorted numerically by calling 1st.sort(), and can be printed with print(1st).  You can assume that every entry is either a valid integer or is the letter 'q'. Examples: If the input is  4 3 6 7 3 q The output is  [3, 3, 4, 6, 7] 4 If input is  4 3 6 7 3 2 q The output is  [2, 3, 3, 4, 6, 7] 4

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

A user is going to enter numbers one at a time, entering 'q' when finished. Put the numbers in a list, sort it in numerical order, and print out the list. Then print out the middle element of the list. (If the list has an even number of elements, print the one just after the middle.)

Remember that a list 1st of numbers can be sorted numerically by calling 1st.sort(), and can be printed with print(1st). 

You can assume that every entry is either a valid integer or is the letter 'q'.

Examples:

If the input is 

4

3

6

7

3

q

The output is 

[3, 3, 4, 6, 7] 4

If input is 

4

3

6

7

3

2

q

The output is 

[2, 3, 3, 4, 6, 7] 4

library> COMS 127: Introduction to Programming for Problem Solving home > 38.6: Problem F5
EzyBooks catalog
Help/FAQ
A user is going to enter numbers one at a time, entering 'q' when finished. Put the numbers in a list, sort it in numerical order, and print out
the list. Then print out the middle element of the list. (If the list has an even number of elements, print the one just after the middle.)
Remember that a list 1st of numbers can be sorted numerically by calling 1st.sort(), and can be printed with print(1st).
You can assume that every entry is either a valid integer or is the letter 'q'.
Examples:
If input is
4.
3.
7.
The output is
[3, 3, 4, 6, 7] 4
If input is
The output is
[2, 3, 3, 4, 6, 7] 4
3.
436 732 O
Transcribed Image Text:library> COMS 127: Introduction to Programming for Problem Solving home > 38.6: Problem F5 EzyBooks catalog Help/FAQ A user is going to enter numbers one at a time, entering 'q' when finished. Put the numbers in a list, sort it in numerical order, and print out the list. Then print out the middle element of the list. (If the list has an even number of elements, print the one just after the middle.) Remember that a list 1st of numbers can be sorted numerically by calling 1st.sort(), and can be printed with print(1st). You can assume that every entry is either a valid integer or is the letter 'q'. Examples: If input is 4. 3. 7. The output is [3, 3, 4, 6, 7] 4 If input is The output is [2, 3, 3, 4, 6, 7] 4 3. 436 732 O
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr