My Carelessness

Back to your page!


Or leave your comments here.

RegendLa

导航

倒三角形

Q:输入正整数n<=20,输出一个n层的倒三角形。例如,n=5时:

#########

-#######

--#####

---###

----#

('-'为空格)

S:

#include <stdio.h>
int main()
{
	int j,i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<i;j++)
		{
			printf(" ");
		}
		for(j=0;j<=2*n-2*(i+1);j++)
		{
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
	return 0;
}

 

posted on 2015-01-27 11:25  最爱七  阅读(346)  评论(0编辑  收藏  举报




Thanks for your coming!
If what you read helps,I would appreciate!