You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
C/菱形打印.c

31 lines
517 B

#include <stdio.h>
int main()
{
int h,i,j,n;
scanf("%d",&n);
int k=(n+1)/2;
for(i=1;i<=k;i++){
for(j=1;j<=n-2*i+1;j++){
printf(" ");
}
for(j=1;j<=2*i-1;j++){
printf("* ");
}
printf("\n");
}
for(i=n-k;i>=1;i--){
for(j=1;j<=n-2*i+1;j++){
printf(" ");
}
for(j=1;j<=2*i-1;j++){
printf("* ");
}
printf("\n");
}
return 0;
}