Update 输出菱形图形.c

master
pwjku6f2y 3 years ago
parent be4ab8bade
commit 3603dabfc6

@ -3,27 +3,27 @@ void diamond(int a)
{ {
int b,c,d,t; int b,c,d,t;
d=0; d=0;
t=a;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>t t=a;//将初始数数据给t
while(a--)//<EFBFBD>ո<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD> while(a--)//空格数逐层递减
{ {
for(b=0; b<a; b++) for(b=0; b<a; b++)
{ {
printf(" "); printf(" ");
} }
printf("*"); printf("*");
for(c=1; c<d; c++)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>ո<EFBFBD><EFBFBD><EFBFBD> for(c=1; c<d; c++)//菱形内部空格数
{ {
printf("*"); printf("*");
} }
if(d!=0)printf("*"); if(d!=0)printf("*");
printf("\n");//һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> printf("\n");//一行输出结束
d=d+2; d=d+2;
}//<EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD><EFBFBD>ϰ벿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> }//菱形的上半部分输出结束
a=t; a=t;
d=d-2; d=d-2;
a= a- 1; a= a- 1;
d=0; d=0;
while(a--)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD><EFBFBD>°벿<EFBFBD><EFBFBD> while(a--)//输出菱形的下半部分
{ {
for(c=1; c<(t-a); c++) for(c=1; c<(t-a); c++)
{ {

Loading…
Cancel
Save