You are given ? data where each data consists of ID, name, and heigh in foot and inch. Then, there are ? queries. For each query, given a variable ? which represents a height in cm. You are asked for help to display all data whose height is less than or equal to ?, ordered descending by the height. If there are 2 data which has the same height, sort ascending by the ID. If no data satisfies the query, output “-1”. Note that 1 foot = 12 inch, and 1 inch = 2,54 cm. Input Format The first line consists of an integer ?. The next ? lines consists of the given data in the format “A,B,C D” where A, B, C, and D represent ID, name, height in feet, and height in inch, respectively. The next line consists of an integer ?. The next ? lines consist of an integer ? which represents the query. Output Format Each query is started by “Q”, followed by the query number started from 1, followed by “:”. For each query, if there is data to display, then output the data sorted descending based on the height with the following format: “ ”. If there is no data to display, output “-1”. Constraints • 1 ≤ ? × ? ≤ 5 × 104 • ID is an integer between 1 and ?. It is guaranteed that 2 data will not have the same ID. • Length of each name is between 1 and 20 (inclusive). Names consist of Latin alphabet or whitespace. It is guaranteed that the first and last character are not whitespaces. • Height in foot is between 0and 7 (inclusive). Height in inch is between 0 and 11 (inclusive). • 1 ≤ ? ≤ 200 • 1 ≤ ? ≤ 102

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

( Use only C Programming Languange)

You are given ? data where each data consists of ID, name, and heigh in foot and inch. Then, there are ? queries. For each query, given a variable ? which represents a height in cm. You are asked for help to display all data whose height is less than or equal to ?, ordered descending by the height. If there are 2 data which has the same height, sort ascending by the ID. If no data satisfies the query, output “-1”.

Note that 1 foot = 12 inch, and 1 inch = 2,54 cm.

Input Format

The first line consists of an integer ?.

The next ? lines consists of the given data in the format “A,B,C D” where A, B, C, and D represent ID, name, height in feet, and height in inch, respectively.

The next line consists of an integer ?.

The next ? lines consist of an integer ? which represents the query.

Output Format

Each query is started by “Q”, followed by the query number started from 1, followed by “:”.

For each query, if there is data to display, then output the data sorted descending based on the height with the following format: “<ID><Name><Height in cm> ”.

If there is no data to display, output “-1”.

Constraints

• 1 ≤ ? × ? ≤ 5 × 104

• ID is an integer between 1 and ?. It is guaranteed that 2 data will not have the same ID.

• Length of each name is between 1 and 20 (inclusive). Names consist of Latin alphabet or whitespace. It is guaranteed that the first and last character are not whitespaces.

• Height in foot is between 0and 7 (inclusive). Height in inch is between 0 and 11 (inclusive). • 1 ≤ ? ≤ 200

• 1 ≤ ? ≤ 102

Sample Input
Sample Output
Q1:
2 Anonymous 162.56
5
1, John Doe,4 6
2, Anonymous, 5 4
3, Vohu Manah, 6 1
4, Dora Hariwini,5 4
5, Kyo,6 7
3
4 Dora Hariwini 162.56
1 John Doe 137.16
Q2:
-1
Q3:
3 Vohu Manah 185.42
2 Anonymous 162.56
4 Dora Hariwini 162.56
165
130
200
1 John Doe 137.16
Transcribed Image Text:Sample Input Sample Output Q1: 2 Anonymous 162.56 5 1, John Doe,4 6 2, Anonymous, 5 4 3, Vohu Manah, 6 1 4, Dora Hariwini,5 4 5, Kyo,6 7 3 4 Dora Hariwini 162.56 1 John Doe 137.16 Q2: -1 Q3: 3 Vohu Manah 185.42 2 Anonymous 162.56 4 Dora Hariwini 162.56 165 130 200 1 John Doe 137.16
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Literals
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education