#T545. 同行列对角线的格

同行列对角线的格

Description

Input three natural numbers N,i,jN, i, j (1iN1 \leq i \leq N, 1jN1 \leq j \leq N), and output the positions of all squares in an N×NN \times N chessboard (where rows and columns are numbered starting from 1) that are in the same row, same column, or same diagonal as the square (i,j)(i, j).

For example: When n=4n=4, i=2i=2, j=3j=3, it represents the square in the second row and third column of the chessboard.

When n=4n=4, i=2i=2, j=3j=3, the output is:
(2,1) (2,2) (2,3) (2,4) Positions of squares in the same row
(1,3) (2,3) (3,3) (4,3) Positions of squares in the same column
(1,2) (2,3) (3,4) Positions of squares on the top-left to bottom-right diagonal
(4,1) (3,2) (2,3) (1,4) Positions of squares on the bottom-left to top-right diagonal

Input Format

One line containing three natural numbers NN, ii, jj, separated by single spaces (1N101 \leq N \leq 10).

Output Format

First line: Output the positions of squares in the same row from left to right;
Second line: Output the positions of squares in the same column from top to bottom;
Third line: Output the positions of squares on the top-left to bottom-right diagonal;
Fourth line: Output the positions of squares on the bottom-left to top-right diagonal.

Each square position should be formatted as: (x,y)(x,y), where xx is the row number and yy is the column number, using English punctuation with no spaces in between. Separate adjacent square positions with a single space.

4 2 3
(2,1) (2,2) (2,3) (2,4)
(1,3) (2,3) (3,3) (4,3)
(1,2) (2,3) (3,4)
(4,1) (3,2) (2,3) (1,4)

源码

CodesOnline