10pt。。。

P1319 压缩技术

Foggy_night @ 2023-07-03 23:18:45

#include<iostream>
using namespace std;
int a[205]; 
int main(){
    int n, x = 1, s = 0;
    bool flag = false;
    cin >> n;
    while(cin >> a[x++]);
    for(int i = 1; i <= x; i++){
        s += a[i];
        if(s > n){
            s %= n;
            if(s == 0)
                cout << endl;
            for(int j = 1; j <= a[i]-s; j++)
                if(flag == false)
                    cout << 0;
                else cout << 1;

            cout << endl; 

            for(int j = 1; j <= s; j++){
                if(flag == false)
                    cout << 0;
                else cout << 1;
            }   
        }
        else {
            for(int j = 1; j <= a[i]; j++){
                if(flag == false)
                    cout << 0;
                else cout << 1;
            }   
        }
        if(!flag) flag = true;//修改01,true则为1,false则为0 
        else flag = false;
    }
    return 0;
}

by vzcx_decipher @ 2023-07-04 08:01:11

这种方法处理基本没救,换种方式处理吧


|