|
|
发表于 2020-11-18 20:27:10
|
显示全部楼层
本楼为最佳答案
- #include <stdio.h>
- int main(void)
- {
- int d , i , j ;
- scanf("%d" , & d) ;
- for(i = 0 ; i < d ; i ++) {
- for(j = d - i - 1 ; j ; j --) printf(".") ;
- for(j = 0 ; j < i * 2 + 1 ; j ++) printf("*") ;
- for(j = d - i - 1 ; j ; j --) printf(".") ;
- printf("\n") ;
- }
- }
复制代码
编译、运行实况
- D:\00.Excise\C>g++ -o x x.c
- D:\00.Excise\C>x
- 4
- ...*...
- ..***..
- .*****.
- *******
- D:\00.Excise\C>x
- 5
- ....*....
- ...***...
- ..*****..
- .*******.
- *********
- D:\00.Excise\C>x
- 6
- .....*.....
- ....***....
- ...*****...
- ..*******..
- .*********.
- ***********
- D:\00.Excise\C>
复制代码 |
|