C语言输出三角形菱形
题目4:打印出如下图案(三角和菱形)
*
***
******
********
******
***
*
1
#include
main int i,j,k,p,t,n; printf "shuru yige shuzi \n" ; scanf "%d",&n ; for i 1;i n;i++ for j 2*i-1;j 0;j-- printf "*" ; printf "\n" ; for i n-2;i 0;i-- for j 2*i;j 0;j-- printf "*" ; printf "\n" ; 2
#include
main int a 4,b,c,d,e; for b a;b 0;b-- for c 2*b-2;c 0;c-- printf " " ; d a-b; for e 4*d+1;e 0;e-- printf "*" ; printf "\n" ; for b 1;b a;b++ for c 2*b;c 0;c-- printf " " ; d a-b-1; for e 4*d+1;e 0;e-- printf "*" ; printf "\n" ; getch ; (3)
#include
main int a,b,c,d; printf "输入一个数:\n" ; scanf "%d",&a ; for b a;b 0;b-- for c a;c b;c-- printf " " ; for d 2*b-1;d 0;d-- printf "*" ; printf "\n" ; *****************
***************
************* ***********
*********
*******
***** *** *
*
*******
*************
*****************
*************
*******
*