21.输出图形

        *
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*

#include<iostream>
using namespace std;

int main()
{
    for(int i=0;i<5;i++)
    {
        for(int j=1;j<=4-i;j++)
        {
            cout<<" ";
        }
        for(int k=1;k<=2*i+1;k++)
        {
            cout<<"*";
        }
        cout<<endl;
    }
    for(int m=3;m>=0;m--)
    {
        for(int n=1;n<=4-m;n++)
        {
            cout<<" ";
        }
        for(int p=1;p<=2*m+1;p++)
        {
            cout<<"*";
        }
        cout<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/jixiaowu/p/3894197.html