记:
这里用到了printf("%*s%s%*s\n",n-i,"",arr,n-i,"");的写法,
其中%*s中的*代表该字符串s的个数,s为给字符串,
这写法一般用在打印中
AC代码:
#include <stdio.h>
#define MAX 50 int main(void)
{
int i,n;
char arr[MAX+];
scanf("%d",&n);
sprintf(arr,"%s","*");
for (i = ; i <= n ; i ++)
{
printf("%*s%s%*s\n",n-i,"",arr,n-i,"");
sprintf(arr,"%s%s",arr,"**");
} return ;
}