#CCBCHBA0000110. Printing Pattern Using Loops
Printing Pattern Using Loops
Printing Pattern Using Loops
Source: HackerRank
Version: Phuoc Hung OJ Extended
Problem Statement
Given , print a -by- square. Each cell on the outer border contains ; values decrease by one at each concentric layer until the central value is 1. Adjacent numbers are separated by one space, with no trailing spaces.
Input
One line contains integer .
Output
Print exactly rows.
Subtasks
-
Subtask 1 (20%): .
-
Subtask 2 (30%): .
-
Subtask 3 (50%): .
Examples
Example 1
Input:
2
Output:
2 2 2
2 1 2
2 2 2
Explanation:
The square has side length 3; outer cells contain 2 and the center contains 1.
Example 2
Input:
1
Output:
1
Explanation:
The square has side length 1; outer cells contain 1 and the center contains 1.