Triangle, a geometric shape composed of three sides and three angles, may seem simple, but it is rich in meaning andcharm is infinite. It has wide applications in various fields such as mathematics, art, architecture, and nature. First of all, the triangle is one of the most basic geometric shapes, and its stability is its most significant characteristic. No matter what force is applied, the shape of the triangle will not change. This stability provides the possibility for the application of triangles in architecture and engineering./////////////////////////////////////////////////////////////////
First, we need to clarify what a triangle is:A closed figure formed by connecting three line segments that are not collinear in the same plane, is one of the most basic shapes in geometry. It has the following key features: Components:3 vertices, 3 sides, 3 interior angles, with a sum of interior angles equal to 180°. Classification methods – By sides: Equilateral triangle (all three sides are equal); Isosceles triangle (two sides are equal); Scalene triangle (all three sides are different). – By angles: Acute triangle (all three angles are acute, i.e., less than 90°); Right triangle (one angle is 90°); Obtuse triangle (one angle is greater than90° and less than180°).Now let’s draw a triangle using Scratch!
Why do we turn right by 360/3 degrees?In this Scratch program, “turn right 360/3 degrees” (i.e., turn right 120 degrees) is to allow the character to draw the shape of a triangle. – A triangle has 3 sides, and to form a closed triangle, the character needs to turn at a fixed angle after drawing each side, repeating this 3 times to return to the initial direction. – A full circle is 360 degrees, divided into 3 equal parts, each part is (360/3 = 120°). By turning right 120 degrees each time and repeating 3 times, the character’s orientation will return to the starting direction, thus drawing a closed triangle (equilateral triangle).
After understanding, let’s try to solve a problem:First, look at the problem:
Problem analysis:
To solve the triangle judgment problem, we can follow the “input acquisition – condition judgment – result output” approach, with the core being the application of the triangle inequality theorem for logical judgment.
1. Input acquisition
Using Scratch’s “ask and wait” block, we sequentially obtain the lengths of the three sides of the triangle input by the user, storing them in variables<span>a</span>、<span>b</span>、<span>c</span> for subsequent calculations and judgments.
2. Condition judgment
According to the triangle inequality theorem, the following three conditions must be satisfied simultaneously:
a+b>c
a+c>b
b+c>a
Using Scratch’s “if… then… else” block, combined with the “and” 【conditions must be satisfied simultaneously】 logical operation, verify whether these three conditions are met.
3. Result output
- If all three conditionsare satisfied, let the cat say “Conditions are met, a triangle can be formed”, and display for 2 seconds;
- If any of the three conditionsis not satisfied, let the cat say “Conditions are not met, please restart the program”, and display for 2 seconds.
Result display:
The problem is relatively simple, and we can also use C++ to solve it:


Code explanation:
- Variable type: Use
<span>double</span>instead of<span>int</span>, to support input of decimal side lengths (e.g., 2.5, 3.8, etc.), making it more widely applicable. - Input interaction: Add a prompt
<span>Please enter the lengths of the three sides of the triangle (separated by spaces, supporting decimals):</span>, to clarify the operation method for the user. - Condition logic: Use
<span>&&</span>(logical AND) to ensure that all three inequalities are satisfied, fully adhering to the triangle inequality theorem. - Result output: Directly feedback the judgment result, clear and easy to understand.