九度 OJ 1065:输出梯形

来源:互联网 发布:红蜘蛛端口号怎么修改 编辑:程序博客网 时间:2024/06/04 07:12
题目1065:输出梯形

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:6707

解决:3647

题目描述:

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

输入:

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

输出:

h所对应的梯形。

样例输入:
4
样例输出:
      ****    ******  ******************
提示:

梯形每行都是右对齐的,sample中是界面显示问题

来源:

2001年清华大学计算机研究生机试真题(第II套)


#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std; int main(void){        int h;        while(scanf("%d",&h) != EOF)        {                int i,j;                for(i = 1; i <= h; ++i)                {                        for(j = 1; j <= 2 * h - 2 * i; ++j)                                printf(" ");                        for(j = 2 * h - 2 * i + 1; j <= 3 * h - 2; ++j)                                printf("*");                        printf("\n");                }        }        return 0;}/**************************************************************    Problem: 1065    User: th是个小屁孩    Language: C++    Result: Accepted    Time:230 ms    Memory:1020 kb****************************************************************/


0 0
原创粉丝点击