print result:
![在这里插入图片描述]()
c
#include <stdio.h>
int main(){
int n;
int m;
scanf("%d",&n);
for(int i = 1;i <= n;i ++){
for(int j = 0;j < n - i;j ++){
printf(" ");
}
for(int k = 0;k < 2 * i - 1;k++){
printf("*");
}
printf("\n");
}
for(int i = 1;i < n;i ++){
for(int j = 0;j < i;j ++){
printf(" ");
}
m = 2 * n - 1;
for(int k = 0;k < m - 2 * i;k++){
printf("*");
}
printf("\n");
}
}
python
def print_up_triangle(n):
""" to count the space of each line: """
j=n-1
for i in range(0,n):
print(j*' '+(i*2+1)*'*')
j-=1
def print_down_triangle(n):
""" to count the space of each line: """
j=1
for i in range(n-2,-1,-1):
print(j*' '+(2*i+1)*'*')
j+=1
""" the scale n is the sequence:n= 0,1,2,3,...n """
def print_diamond(n):
print_up_triangle(n)
print_down_triangle(n)
scale=input("input a integer to specify the scale of the diamond to be print: ")
scale=(int)(scale)
print_diamond(scale)