2025-03-06 22:45:14 +08:00

32 lines
548 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
编写程序打印一个n行的菱形n由键盘输入
输入5
输出:
*
***
*****
***
*
-----------------------------------------------------*/
#include <stdio.h>
#include <math.h>
main()
{
int i,j,k,n;
printf("请输入一个奇数(行数)n:");
scanf("%d",&n);
for(i=-n/2; i<=n/2;i++)
{
/**********Program**********/
for(j=0;j<abs(i);j++){
printf(" ");
}
for(k=0;k<n-j*2;k++){
printf("*");
}
printf("\n");
/********** End **********/
}
}