全RE,求助Dalao啊

P1319 压缩技术

snow_y @ 2023-04-06 15:33:58

#include<iostream>
using namespace std;
int a[1000], b[1000];
int main()
{
    int n, x, i, sum = 0, cnt = 0;
    cin >> n;
    for (i = 0; i < 202; i++)
    {
        cin >> x;
        if (sum <= n * n) {
            sum += x;
            b[i] = x;
            cnt++;
        }
        else break;
    }
    int num = b[0];
    for (i = 1; i < cnt; i++)
    {
         while (num < (num + b[i]))
           {
                if (i % 2 == 0) {
                    a[num] = 0;
                    num++;
                }
                else {
                    a[num] = 1;
                    num++;
                }
            }
        }
        for (i = 0; i < n*n; i+=n)
        {
            for (int j = 0; j < n; j++)
            {
                cout << a[i];
            }
            cout << endl;
        }
        return 0;
    }

by OURUO @ 2023-04-06 16:31:04

这题很水,只用注意输出回车和0与1的循环输出就行了

#include <iostream>
using namespace std;
int main(){
    int a,n,t=0,i=0,b,s=0;
    cin>>n;
    while(s<n*n){
        cin>>a;
        i++;
        for(b=a;b>=1;b--){
            if(t==n){
         cout<<endl;
          t=0;
         }
            if(i%2==1)cout<<0;
            else cout<<1;
            t++;
            s++;
            }
        }
    cout<<endl;
    return 0;
}

by tianzheyu @ 2023-08-25 17:37:38

#include<bits/stdc++.h>
using namespace std;
int a[40001];
int main()
{
    int n,num,js=0;
    bool sc=0;
    cin>>n;
    while(cin>>num)
    {
        for(int i=1;i<=num;i++)
        {
            js++;
            a[js]=sc;
        }
        sc=!sc;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            cout<<a[(i-1)*n+j];
        cout<<endl;
    }
    return 0;
}

|