c++用for循环怎么打印这个图形

img


#include <iostream>
using namespace std;
int main()
{
    int i,j;
    for (i=0;i<9;i++)
    {
        if(i<=4)
        {
            for (j=0;j<10;j++)
            {
                if( j>=5-i && j<5+i)
                    cout << " ";
                else
                    cout << "*";
            }
        }else
        {
            for (j=0;j<10;j++)
            {
                if(j >= i-3 && j<=12-i )
                    cout << " ";
                else
                    cout << "*";
            }
        }
        cout <<endl;
    }
    return 0;
}



#include<stdio.h>
int main() {
    printf(
    "* * * * * * * * * *\n"
    "\n"
    "* * * *     * * * *\n"
    "\n"
    "* * *         * * *\n"
    "\n"
    "* *             * *\n"
    "\n"
    "*                 *\n"
    "\n"
    "* *             * *\n"
    "\n"
    "* * *         * * *\n"
    "\n"
    "* * * *     * * * *\n"
    "\n"
    "* * * * * * * * * *\n"
    );
    return 0;
}

不需要for