编程打印下列图形(行数为n行)

2025-04-14 00:22:12
推荐回答(1个)
回答1:

#include 
void printMap(int n)
{
     int i,j,k;
     for(i=0;i     {
        for(j=i;j            printf("  ");
        for(k=0;k<2*i+1;k++)
            printf("* ");
for(j=i;j            printf("  ");
for(j=i;j            printf("  ");
        for(k=0;k<2*i+1;k++)
            printf("* ");
        printf("\n");
     }
}
void main()
{
    int n=9;
   
    printMap(n);
}

 

---------- run ----------

                *                                 * 

              * * *                             * * * 

            * * * * *                         * * * * * 

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

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

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

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

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

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


Output completed (0 sec consumed) - Normal Termination