OJ_1065

来源:互联网 发布:从事大数据需要学什么 编辑:程序博客网 时间:2024/05/18 03:04
#include <iostream>#include <stdlib.h>using namespace std;void func(){    int h;    while(cin>>h)    {                 int len=h+2*(h-1);                 for(int i=1;i<=h;i++)                 {                         for(int j=1;j<=len-(h+2*(i-1));j++)                         {                                 cout<<" ";                         }                         for(int j=1;j<=h+2*(i-1);j++)                         {                                 cout<<"*";                         }                         cout<<endl;                 }    }      }int main(int argc, char *argv[]){    //printf("Hello, world\n");func();return 0;}

算空格

题目描述:

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

输入:

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

输出:

h所对应的梯形。

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

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


0 0