咋写,来个人帮我啊下,谢了

img

如果有帮助请点一下我回答右上方的采纳,谢谢!以后有什么问题可以互相交流


#include <iostream>
using namespace std;
int main()
{
    int N ;
    cin>>N;
    for (int i = 1; i <= N; i++)
    {
        if(i%2==1){
            for (int j = 1; j <= N - i; j++)
            {
                cout << " ";
            }
            for (int k = 1; k <= i; k++)
            {
                cout << "* ";
            }
            cout << endl;
        }
        
    }
    for (int i = 1; i <= N; i++)
    {
        if(i%2==1){
            for (int j = 1; j <= i+1; j++)
            {
                cout << " ";
            }
            for (int k = 1; k <= N - i-1; k++)
            {
                cout << "* ";
            }
            cout << endl;
            
        }
    }
    return 0;
}

img

如有帮助,请点击我回答右上角的【灰色采纳】按钮支持一下,谢谢。

#include <iostream> 
using namespace std; 
int main(){
    int n;
    cin>>n; 
    for(int i = 1; i <= n/2+1; i++){ // 上半三角
        for(int j = 1; j <= n/2+1 - i; j++){ // 打印空格
            cout << ' ';
        }
        for(int j = 1; j <= 2 * i - 1; j++){ // 打印*号
            cout << '*';
        }
        cout << endl;
    }
    for(int i = 1; i <= n/2; i++){ // 下半三角
        for(int j = 1; j <= i; j++){ // 打印空格
            cout << ' ';
        }
        for(int j = 1; j <= n - 2 * i; j++){ // 打印*号
            cout << '*';
        }
        cout << endl;
    }
    return 0;
}

img

这才是你要的!!!

#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int m = n/2+1;
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n/2-i;j++)
            cout<<"  ";
        for(int j=0;j<i*2+1;j++)
            cout<<"* ";
        cout<<endl;
    }
    for(int i=0;i<m-1;i++)
    {
        for(int j=0;j<i+1;j++)
            cout<<"  ";
        for(int j=0;j<n-i*2-2;j++)
            cout<<"* ";
        cout<<endl;
    }

    return 0;
}