C++用for循环怎么打印这个图形呢?

C++用for循环怎么打印这个图形呢?

img

供参考:

#include<iostream>
using namespace std;
int main()
{
    int row, x, y, nrows = 6;
    for (row=1;row<=nrows;row++)        //_________________________)
    {
        for (x=1;x<=nrows-row;x++)      // ____; x <= _____; x++)
            cout << "#";
        for (y=1;y<=2*row-1;y++)      //____; y <=______; y++)
            if (y%2==1)                 //__________________________)
                cout <<"*";              // ___________;
            else
                cout <<"#";              //___________;
        for (x = 1;x<=nrows-row;x++)    //__________; x++)
            cout << "#";
        cout << endl;
    }
    return 0;
}

供参考:

#include<stdio.h>
int main()
{
  int i,j,n=6;
  //scanf("%d",&n);
  for(i=0;i<n;i++)
  {
      for(j=i;j<n-1;j++)
          printf("#");
      for(j=0;j<2*i+1;j++)
          printf("%c",(j%2==0)?'*':'#');
      for(j=i;j<n-1;j++)
          printf("#");
      printf("\n");
  }
  return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main() 
{
    for (int i = 0; i < 6; i++)
    {
        for (int j = 1; j <= 6-i; j++)
        {
            if (j == 6 - i)
            {
                cout << "*";
                for (int n = 0; n < i; n++)
                {
                    cout << "#*";
                }
                for (int m = 0; m < 5 - i; m++)
                {
                    cout << "#";
                }
            }
            else
            {
                cout << "#";
            }
        }
        cout << endl;
    }
    system("pause");
    return 0;
}