1933:输出梯形

问题 A: 输出梯形

时间限制: 1 Sec  内存限制: 32 MB
提交: 700  解决: 265
[提交][状态][讨论版][命题人:外部导入]

题目描述

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

输入

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

输出

h所对应的梯形。

样例输入

5

样例输出

        *****
      *******
    *********
  ***********
*************
#include<iostream>
using namespace std;

int main() {
	int h;
	while (cin >> h) {
		for (int i = 0; i < h; i++) {
			int k = 2 * h;
			int x = 0;
			while (k-- > i * 2 + 2) {
				cout << " ";
			}
			while (x++ < h + 2 * i) {
				cout << "*";
			}
			cout << endl;
		}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_36502291/article/details/82142990
今日推荐