标签:字符 算法 printf oid 图片 ima bsp scanf algo-1
记:
这里用到了printf("%*s%s%*s\n",n-i,"",arr,n-i,"");的写法,
其中%*s中的*代表该字符串s的个数,s为给字符串,
这写法一般用在打印中
AC代码:
1 #include <stdio.h> 2 #define MAX 50 3 4 int main(void) 5 { 6 int i,n; 7 char arr[MAX+1]; 8 scanf("%d",&n); 9 sprintf(arr,"%s","*"); 10 for (i = 1 ; i <= n ; i ++) 11 { 12 printf("%*s%s%*s\n",n-i,"",arr,n-i,""); 13 sprintf(arr,"%s%s",arr,"**"); 14 } 15 16 return 0; 17 }
标签:字符 算法 printf oid 图片 ima bsp scanf algo-1
原文地址:https://www.cnblogs.com/mind000761/p/8874760.html