Queens (2)

Write a program to print all the ways to place n queens on an n × n
chessboard so that no queen threatens another queen.

Input

Input consists of a natural number n > 0.

Output

Print all the ways to put n queens on an n × n chessboard so that no
queen threatens another queen. The queens must be marked with a ‘Q’, and
the empty positions with a dot. Print an empty line after each board.

Information about the checker

You can print the solutions to this exercise in any order.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:19:44.033Z

© Jutge.org, 2006–2026.
https://jutge.org
