✔ 最佳答案
閣下可以試一下以下的algorithm:
1. Define variable side as integer
2. Define variables i, j as integer
3. Display "Please input the length of one side of the square: "
4. Read user input and store as side
5. if side is greater than zero
5.1 if side is greater than 1
5.1.1 if side is greater than or equal 2 (* display top side *)
5.1.1.1 for i equals 1 to side
5.1.1.1.1 display "*"
5.1.1.2 Display line feed
5.1.2 if side is greater than 2 (* display left right sides *)
5.1.2.1 for i equals 2 to side - 1
5.1.2.1.1 Display "*"
5.1.2.1.2 for j equals 1 to side - 1
5.1.2.1.2.1 Display blank character
5.1.2.1.3 Display line feed
5.1.1 if side is greater than or equal 2 (* display bottom side *)
5.1.1.1 for i equals 1 to side
5.1.1.1.1 display "*"
5.1.1.2 Display line feed
5.2 else
5.2.1 Display "*" and line feed
6 else
6.1 Display "Please input length of positive value!"