输出梯形

题目描述

输入一个高度h,输出一个高为h,上底边为h的梯形。

输入格式

一个整数h(1<=h<=1000)。

输出

h所对应的梯形。

样例输入

5

样例输出

        *****
      *******
    *********
  ***********
*************

#include <iostream>

using namespace std;

int main()
{
   int h;
   cin >> h;
   int maxLine = h+(h-1)*2;
   for(int i=0;i<h;i++){
    for(int j=0;j<maxLine;j++){
        if(j<maxLine-h-2*i)
            cout << " ";
        else
            cout << "*";
    }
    cout << endl;
   }
   return 0;
}

 

posted @ 2018-03-05 16:50  Shaw_喆宇  阅读(214)  评论(0编辑  收藏  举报