求助大佬!!!

P1319 压缩技术

LJC00125 @ 2018-03-16 10:13:26

include<bits/stdc++.h>

using namespace std;

int n,k,sum=0,e=1;

int main()

{

cin >> n;
while (sum<=n*n)
{
    e=1-e;
    scanf("%d",&k);
    for (int i=1;i<=k;i++)
    {
        sum++;
        cout << e;
        if (sum%n==0) cout << endl;
    }
}
return 0;

}


by brealid @ 2018-03-16 12:35:46

@LJC00125

用3个`分别框住顶部和底部


by LJC00125 @ 2018-03-16 15:35:49

include<bits/stdc++.h>
using namespace std;
int n,k,sum=0,e=1;
int main()
{
cin >> n;
while (sum<=n*n)
{
    e=1-e;
    scanf("%d",&k);
    for (int i=1;i<=k;i++)
    {
        sum++;
        cout << e;
        if (sum%n==0) cout << endl;
    }
}
return 0;
}

by LJC00125 @ 2018-03-16 15:36:35

include<bits/stdc++.h> using namespace std; int n,k,sum=0,e=1; int main() { cin >> n; while (sum<=n*n) { e=1-e; scanf("%d",&k); for (int i=1;i<=k;i++) { sum++; cout << e; if (sum%n==0) cout << endl; } } return 0; }


by LJC00125 @ 2018-03-16 15:38:04

include<bits/stdc++.h>
using namespace std;
int n,k,sum=0,e=1;
int main()
{
    cin >> n;
    while (sum<=n*n)
    {
        e=1-e;
        scanf("%d",&k);
        for (int i=1;i<=k;i++)
        {
            sum++;
            cout << e;
            if (sum%n==0) cout << endl;
        }
    }
    return 0;
}

|