求解答ヽ(*。>Д<)o゜(c++)

P1319 压缩技术

LYB23390 @ 2020-11-08 15:30:13

#include<bits/stdc++.h>
using namespace std;

    int a[200];
int main() 
{
    int i,j,n,c=0,l,d=0;
    cin>>n;
    i=0;
    while(scanf("%d",&a[i])==1) i++;
        for(i=0; i<n; i++) {
            for(j=0; j<n; j++)
            {
                if(a[d]==0&&c==0) {
                c=1;
                d++;
                } 
                else 
                    if(a[d]==0&&c==1) 
                {
                    c=0;
                    d++;
                }
                a[d]--;
            }
            cout<<endl;
        }
    return 0;
}

by Dabubu @ 2020-11-10 18:04:50

#include <iostream>
#include <cstdio>

using namespace std;

int table[40005];
int main()
{
    int p = 1;
    int f = 0;
    int n;
    cin >> n;

    int a;
    while (~scanf("%d", &a))
    {
        for (int j = 0; j <a; j++)
        {
            table[p] = f;
            p++;

        }
        if (f == 0)
            f = 1;
        else
            f = 0;
    }
    p = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            cout << table[p];
            p++;
        }
        cout << endl;
    }
    return 0;
}

by LYB23390 @ 2020-11-25 17:28:08

不胜感激


by Deep_Breath @ 2021-02-03 14:19:18

@LYB23390 我屮艸芔茻卧槽您真他妈是太强了


|