题目1065:输出梯形

AC:

#include<iostream>
using namespace std;
int main()
{
	int h;
	while(cin>>h)
	{
		int i,j,k,t;
	    k=(h-1)*2;
		t=h;
	    for (i=0;i<h;i++)//////////////h在此处已用,所以用t=h来代替重用;
	    { 	
	      for (j=0;j<k;j++)
	        cout<<" ";
	        k-=2;
	      for (j=0;j<t;j++)
	         cout<<"*";
	        t+=2;
	        cout<<endl;
	    }
	}
	return 0;
}

  

posted @ 2017-02-27 21:08  贱人郭  阅读(142)  评论(0编辑  收藏  举报