求助大佬,帮改进程序。thankssssssssss!!!

P1319 压缩技术

༺ʚFLYɞ༻ @ 2020-02-04 18:12:04

//方法1

#include<bits/stdc++.h>
using namespace std;
int main()
{   
    int r,n,a,b,c[40001]={0},ans,anss=0;
    cin>>n;
    r=n*n;
    while(r)
    {
        cin>>b>>a;
        r-=a+b;
        ans=b+anss;anss=ans;
        ans=a+anss;
        for(int i=anss+1;i<=ans;i++)
        c[i]=1;
        anss=ans;

    }
    for(int i=1;i<=n*n;i++)
    {
        cout<<c[i];
        if(i%n==0)
            cout<<endl;
    }
    return 0;
}
//方法2
#include<bits/stdc++.h>
using namespace std;
int c,a[21];
int main()
{   
    int k=0,r,n,a,b,c[40001],ans,anss=0;
    cin>>n;
    r=n*n;
    while(r)
    {
        k++;
        cin>>a;r-=a;
        ans=a+anss;
        for(int i=anss+1;i<=ans;i++)
        c[i]=0;
        anss=ans;
        cin>>a;
        r-=a;
        ans=a+anss;
        for(int i=anss+1;i<=ans;i++)
        c[i]=1;
        anss=ans;
    }
    for(int i=1;i<=n*n;i++)
    {
        cout<<c[i];
        if(i%n==0)
            cout<<endl;
    }
    return 0;
}

help


by ༺ʚFLYɞ༻ @ 2020-02-04 18:12:48

在线等


by songxiao @ 2020-03-23 17:14:52

您等了多久了……


|