Write a program to simulate a database server. The program first reads data into the database, and then executes one query command at a time.
The first part of the input is the data. The first line contains the number of records, n. The next n lines each contain one record, with the following fields. Each string’s length does not exceed m.
lastname: stored as a string
firstname: stored as a string
ID: stored as a string
salary: stored as an integer (int)
age: stored as an integer (int)
The second part of the input is the SQL query commands. The first line contains the number of commands, c. Each command has the following format:
select field1 field2 ... fieldk where condition
field can be any of lastname, firstname, ID, salary, age, in any order.
condition is a test condition; only the records satisfying the condition will be output. The format of condition is:
field operator constant
Here, field can be any column.
If the field being compared is a string, operator can be == or !=.
If the field being compared is a number, operator can be ==, >, or <.
The output should be the specified fields of the records that meet the condition, separated by a single space.
Parameter constraints:
0 < n <= 50, 0 < m <= 80, 0 < c <= 100
Numbers or records n.
Next n lines each contain one records, each string's length does not exceed m.
Number of commands c.
Ex. 4
Liu Pangfeng A123456789 80000 40
Wu Janet B123456789 79999 30
Liu Kevin C123456789 0 10
Liu Eric C123456789 0 7
2
select lastname firstname ID where salary > 1000
select firstname salary where lastname == Liu
The specified fields of the records that meet the condition, separated by a single space.
Ex.Liu Pangfeng A123456789
Wu Janet B123456789
Pangfeng Liu 80000 Liu
Kevin 0 Liu
Eric 0 Liu