当前位置:网站首页>Using the for loop to output an alphabetic triangle

Using the for loop to output an alphabetic triangle

2022-06-23 07:41:00 Advanced vegetable bear

subject : Programming , utilize for Loop statement outputs the following graph .

#include<stdio.h>
#include<math.h>
int main()
{
	int i,j,k=1,m=1;
	for(i=1;i<=8;i++)
	{
		for(j=1;j<16-i;j++)
		{
			printf("  ");
		}
		printf("Z ");
		for(j=1;j<(k-1)/2;j++)
		{
			printf("%c ",'Z'-j);
		}
		for(j=(k-1)/2;j>0;j--)
		{
			printf("%c ",'Z'-j);
		}
		if(i==1) printf("\n");
		else
		printf("Z\n");
		k=k+2;
	}
	return 0;
 }

原网站

版权声明
本文为[Advanced vegetable bear]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230652036731.html