77问答网
所有问题
C语言图形题*组成菱形·只能用getchar和for loops TAT
高度一定为奇数~~~~~~~
举报该问题
推荐答案 推荐于2016-05-12
#include <stdio.h>
int main()
{
int row,i,j,N ;
do {
printf("Please enter the height of diamond: " );
scanf("%d", &N );
} while(N%2==0);
N /=2 ;
N +=1 ;
row=1;
while(row<=N) /*前N排星号*/
{
for(i=1;i<=N-row;i++)
printf(" ");
for(j=1;j<=2*row-1;j++)
printf("*");
printf("\n");
row++;
}
row=1;
while(row<=N-1) /*后N-1排星号*/
{
for(i=1;i<=row;i++)
printf(" ");
for(j=1;j<=2*(N-row)-1;j++)
printf("*");
printf("\n");
row++;
}
return 0;
}
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://77.wendadaohang.com/zd/G3vIYN8GqYNv3Yv88WN.html
其他回答
第1个回答 2015-03-15
#include <stdio.h>
#include <math.h>
int main(void)
{
int n,i,j;
scanf("%d",&n);
for(i=-n/2;i<=n/2;i++)
{
for(j=0;j<n-abs(i);j++)
{
if(j<abs(i))
{
putchar(' ');
}
else
{
putchar('*');
}
}
putchar('\n');
}
return 0;
}
第2个回答 2015-03-15
for loops TAT
这是什么意思?我都没听说过!
相似回答
大家正在搜
c语言getchar和scanf
c语言中gets和getchar
c语言get和getchar区别
c语言getchar有什么用
getchar在c语言中怎么用
c语言getchar的功能
c语言用getchar输入字符串
c语言getchar函数用法
c语言中getchar函数的功能