Write a program that prints the number at position i of a given list.
In this exercise, positions are indexed from 0. Position 0 is the first position; Position 1 is the second position; Position 2 is the third position; etc.
Each line of input consists of a number n, followed by n numbers, followed by number i.
For each line of input there should be a line of output with a single integer aᵢ indicating the number at position i of the input list.
The number n and thus the size of the input list will be at most 100.
Example Input
5 1 2 3 4 5 2
4 16 8 4 2 3
3 360 60 1080 0
Example Output
3
2
360
Section 4.8. Sequences of the Computer Science by Example book discusses how to deal with sequences of values, including how to perform indexing of integer sequences.
try first: repeat-list
try next: replace
Copyright © 2020-2022 Rudy Matela
This text is available under the CC BY-SA 4.0 license.
Originally available on cscx.org/index-ints