编写如下图案程序

来源:百度知道 编辑:UC知道 时间:2024/06/23 17:55:31
1 *
###
*****
#######
*********
3
#****
*#***
**#**
***#*
****#

用C语言可以吗??
第一个

#include<stdio.h>
main()
{
int i,j;
for(i=0;i<6;i++)
{
for(j=0;j<i*2+1;j++)
{if(i%2!=0)printf("*");
else printf("#");}
printf("\n");
}
getch();
}

第二个
#include<stdio.h>
main()
{
int i,j;
for(i=0;i<5;i++)
{for(j=0;j<5;j++)
if(j==i)printf("#");
else printf("*");
printf("\n");
}
getch();
}