30分求助!!!!!!!!!!
查看原帖
30分求助!!!!!!!!!!
1127424
damuzhi楼主2023/10/14 17:03
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int f = 0;
    int a[201];
    int i = 0;
    while (f < n * n)
    {

        cin >> a[i];
        f += a[i];
        i++;
    }
    int fj = 0;
    int d[n * n];
    // int j = 0;
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            for (int j = 0; j < a[i]; j++)
            {
                d[fj] = 0;
                fj++;
            }
        }
        if (i % 2 == 1)
        {
            for (int j = 0; j < a[i]; j++)
            {
                d[fj] = 1;
                fj++;
            }
        }
    }
    int fjj = 0;
    for (int i = 0; i < n; i++)
    {
        for (fjj = 0; fjj < n; fjj++)
        {
            cout << d[i * n + fjj];
        }
        cout << endl;
    }
    return 0;
}

2023/10/14 17:03
加载中...