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;
}

 

posted on 2014-08-06 11:50  Ji_xiaowu  阅读(172)  评论(0编辑  收藏  举报

导航