Right-Aligned Number Triangle


Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 10M

Author:
Problem type

Description

請撰寫一個程式,輸入一個正整數 n,並使用 for loop 印出一個「右對齊」的數字三角形。

Requirements

  1. 輸入

    • 一個正整數 n
  2. 輸出:

    • 第 1 行只有一個數字 1
    • 第 2 行為 1 2
    • 第 3 行為 1 2 3
    • 第 n 行為 1 2 ... n,但每一行需「靠右對齊」,左邊用空白 (Space) 填補,使三角形呈現右對齊效果

Input and Output

假設輸入 n5

        1
      1 2
    1 2 3
  1 2 3 4
1 2 3 4 5

Comments

There are no comments at the moment.