输出梯形

注意观察每一行的空格和行数的关系,以及星号和行数的关系。

int n;

int main()
{
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n*2-(i+1)*2;j++) cout<<' ';
            for(int j=0;j<n+i*2;j++) cout<<'*';
            cout<<endl;
        }
    }

    //system("pause");
    return 0;
}
posted @ 2021-01-29 23:34  Dazzling!  阅读(72)  评论(0编辑  收藏  举报