HUAWEI OD machine test real test questions Python to achieve [book hotel] [2022Q4 100 points], with detailed problem-solving ideas

insert image description here

1. Topic description

It’s summer vacation, and Xiao Ming decides to go to a certain tourist attraction. He searches the Internet for hotels of various prices (array A of length n), and his psychological price is x yuan. Please help him to select k hotels closest to x hotels (n>=k>0), and print the hotel prices from low to high.

2. Enter description

First row: n,k, x
Second row: A[o] A[1] A[2]…A[n-1]

3. Output description

Prints the filtered hotel prices from low to high.

4. Problem-solving ideas

  1. Read the input hotel quantity hotelCount, select the quantity selectCount, and psychological price targetPrice;
  2. Create a size of hotelC

Guess you like

Origin blog.csdn.net/guorui_java/article/details/131566003