1. Analysis: First python, we analyze the composition of diamond. Bird seo double happiness input 2, a diamond print three lines; input 3, a diamond print five elements. That is, according to the digital input A, the first diamond print line 2a-1. A triangle and a diamond by the inverted triangles, two triangles may be printed in a double loop. Printing conditions inverted triangle is the value of a loop counter i is equal to a.
2. Reference code is as follows:
A = int (input ( ">")
C = A
b = a * temporarily in a temporary variable b, and c, a printing cycle to facilitate future values are stored.
For i ranging from (1, a + 1): - a first a circular print layer triangle
print ( "* (c-1 )," * "* (2 * i-1) - print c-1 space ( As used herein, two spaces), 2 * i-1 * with increasing the number of rows is increased
C = C-1-- each additional line, a line space is reduced
if (i = a): - critical condition, inverted triangle is printed
for the range (1, a) of y: - ---- cycle inverted triangle Print
print ( "* y," * "* (2 * b-3) - y print spaces, 2 * b-3 * increases accompanying the digital
B = B-1- * for each additional line is reduced