我也全WA了

P1319 压缩技术

COUPDETAT @ 2018-03-13 12:49:30

include<iostream>

using namespace std; int s[66666]; int main() { int a,b,sum=1; cin>>a; int i=1; while(cin>>b) { if(i%2!=0) for(int j=1;j<=b;j++) {s[sum]=0; sum++; } else for(int j=1;j<=b;j++) { s[sum]=1; sum++; } i++; } for(int j=1;j<=a*a;j++) { cout<<s[j]; if(j%7==0) cout<<endl; } return 0; }


by 扩散性百万甜面包 @ 2018-03-13 13:00:48

学会使用markdown,我骄傲我自豪


by 扩散性百万甜面包 @ 2018-03-13 13:18:00

#include <iostream>
using namespace std;
int tot, n;
inline void PRINT(int x, int b)
{
    for (int i = 0; i < x; i++)
    {
        if (++tot > n)
        {
            cout << endl;
            tot = 1;
        }
        cout << b;
    }
}
int main()
{
    cin >> n;
    int x;
    bool zero = 0;
    while (cin >> x)
    {
        PRINT(x, zero);
        zero = !zero;
    }
    return 0;
}

|