Array practice 2
This practice problem will require you to programme basic array [list] operations.
You are hired to offer phone number look up service for a company's internal network. The company has \(N\) employees with employee ID \(0\) to \(N-1\). Your job is to when asked for the phone number for employee \(i\), output that person's number on screen.
In addition, you are also being asked to update the directory. Aside from enquiries, your boss may ask you to update an employee's number from time to time, and you should do so.
Input Specification
The first line will contain two integers \(N\) and \(M\) (\(1 < N,M < 10000\)), indicating the number of employees in your directory, and the number of queries/requests.
The following \(N\) lines will each contain a single integer \(P\) (\(1 < P < 1000000\)), indicating an employee's phone number.
Then, the next \(M\) lines will each contain first an integer \(t\) (\(t \in {0,1}\)) indicating the request type.
If \(t\) is 0, then it will be followed by a query for phone number by a single integer, which is the employee's ID.
If \(t\) is 1, then it will be followed by an employee ID in integer \(i\), then another integer \(k\) with the new phone number.
Output Specification
There should be \(M\) lines in your output, each an integer for the phone number that is asked.
Should the query ask for an employee not on the directory (\(P > N-1\)), output
No entry
.
Should the query ask you to update a phone number, output New number for i
is k
, where \(i\) is the employee ID and \(k\) the new number.
Sample Input 1
5 5
1024
2048
7789
4321
42
0 2
0 7
0 3
1 2 1111
0 2
Sample Output 1
7789
No entry
4321
New number for 2 is 1111
1111
Sample Input 2
3 3
12
34
56
1 10 24
1 2 10
0 2
Sample Output 2
No entry
New number for 2 is 10
10
Comments