石家庄中山华府:帮忙编程序,用C语言,输出如下图形!

来源:百度文库 编辑:高考问答 时间:2024/05/02 16:10:14
*
***
*****
*******
*****
***
*

我做过答的
#include<stdio.h>
main()
{
int i,j;
for(i=1;i<=7;i+=2)
{
for(j=1;j<=i;j++)
printf("*");
printf("\n");
}
for(i=5;i>=1;i-=2)
{
for(j=1;j<=i;j++)
printf("*");
printf("\n");
}
}

#include<stdio.h>
#include<conio.h>
main()
{
printf("*\n");
printf("***\n");
printf("*****\n");
printf("*******\n");
printf("*****\n");
printf("***\n");
printf("*\n");
getch();
}

c++代码:
#include<iostream.h>
void main()
{
for(int a=1;a<=7;a+=2)
{
for(int b=1;b<=a;b++)
cout<<'*';
cout<<endl;
}
int c(a-4),d;
for(;c>=1;c-=2)
{
for(d=1;d<=c;d++)
cout<<'*';
cout<<endl;
}
}

#include<stdio.h>
main()
{ int i,j,bianchan;
printf("please input bianchan\n");
scanf("%d",&bianchan);
for(i=1;i<=bianchan;i+=1) /*先打印上半部分*/
{for(j=1;j<=2*i-1;j++) /*每行有2*行序号-1个*号*/
printf("*");
printf("\n");
}
for(i-=2;i>=1;i-=1) /*再打印下半部分*/
{for(j=1;j<=2*i-1;j++)
printf("*");
printf("\n");
}
getchar(); /*暂停让用户看到结果*/
getchar();
}

超简单!