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.
Htu/函数 输出菱形

32 lines
387 B

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