目的是要一个菱形但是为什么输出结果是这样如下图


// 2-9菱形.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
using namespace std;
const int N = 4;
int main()
{
    for (int i = 1; i <= N; i++) {
        for (int j = 1; i <= 30; j++)
            cout << ' ';
        for (int j = 1; j = 8 - 2 * i; j++)
            cout << ' ';
        for (int j = 1; j <= 2 * i - 1; j++)
            cout << "*";
        cout << endl;
   }
    for (int i = 1; i <= N - 1; i++) {
        for (int j = 1; j <= 30; j++)
            cout << ' ';
        for (int j = 1; j < 7 - 2 * i; j++)
            cout << '*';
        cout << endl;
    }
    return 0;
}

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/345693539746156.png "#left")

for (int j = 1; i <= 30//这是啥???; j++)

 for (int j = 1; i <= 30; j++)
            cout << ' ';
        for (int j = 1; j = 8 - 2 * i//这是啥; j++)

循环条件有问题,改好后


// 2-9菱形.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

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