本文共 770 字,大约阅读时间需要 2 分钟。
编写程序打印如下图形
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr(); //to clear the screen
printf(“How many lines?”);
scanf(“%d”,&n);
n*=2;
for(i=0;i<n;i+=2)
{
for(j=n-2;j>i;j-=2)
printf(” “);
for(k=0;k<=i;++k)
printf(“*”);
printf(“n”);
}
for(i=0;i<n;i+=2)
{
for(j=0;j<i;j+=2)
printf(” “);
for(k=n-1;k>i;–k)
printf(“*”);
printf(“n”);
}
getch(); //to stop the screen
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr(); //to clear the screen
printf(“How many lines?”);
scanf(“%d”,&n);
n*=2;
for(i=0;i<n;i+=2)
{
for(j=n-2;j>i;j-=2)
printf(” “);
for(k=0;k<=i;++k)
printf(“*”);
printf(“n”);
}
for(i=0;i<n;i+=2)
{
for(j=0;j<i;j+=2)
printf(” “);
for(k=n-1;k>i;–k)
printf(“*”);
printf(“n”);
}
getch(); //to stop the screen
}
翻译自:
编写程序打印如下图形
转载地址:http://yrwwd.baihongyu.com/