#K6656. List Neighboring Book Pairs
List Neighboring Book Pairs
List Neighboring Book Pairs
Given a shelf with \(N\) books, your task is to list all possible pairs of neighboring books that can be selected. Books are numbered consecutively from 1 to \(N\). If there is less than 2 books, then no pair can be formed.
Example:
Input: 5 Output: 1 2 2 3 3 4 4 5
Note: The output should be printed to standard output, with each valid pair on a new line. Each pair consists of two integers separated by a space representing the consecutive book numbers.
inputFormat
The input is given via standard input (stdin) and consists of a single integer (N), which represents the total number of books on the shelf.
outputFormat
Print each neighboring pair on a separate line in the format "a b", where (a) and (b) are consecutive book numbers. If there are no pairs, do not print anything.## sample
5
1 2
2 3
3 4
4 5
</p>