题目1065:输出梯形时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:1446
解决:784
- 题目描述:
输入一个高度h,输出一个高为h,上底边为h的梯形。
- 输入:
一个整数h(1<=h<=1000)。
- 输出:
h所对应的梯形。
- 样例输入:
4
- 样例输出:
**** ****** ******************
- 提示:
梯形每行都是右对齐的,sample中是界面显示问题
- 来源:
- 2001年清华大学计算机研究生机试真题(第II套)
#include<iostream>using namespace std;#include<iomanip>int main(){ int h; while(cin >> h) { for(int i = 1; i <= h; i++) { cout << setfill(' ') << setw(2*(h-i) + 1); for(int j = 1; j <= h+2*i-2; j++) cout << "*"; cout << endl; } } return 0;}/************************************************************** Problem: 1065 User: true14fans Language: C++ Result: Accepted Time:160 ms Memory:1520 kb****************************************************************/