ccf-201604-2

ccf-201604-2

#include <iostream>
using namespace std;
int main() {
    int a[20][10];
    int b[4][4];
    int c;
    for(int i=0; i<20; i++) {
        for(int j=0; j<10; j++) {
            if(i<4) {
                a[i][j]=0;
            } else if(i==19) {
                a[i][j]=1;
            } else {
                cin>>a[i][j];
            }
        }
    }
    for(int i=0; i<4; i++) {
        for(int j=0; j<4; j++) {
            cin>>b[i][j];
        }
    }
    cin>>c;
    for(int i=0; i<4; i++) {
        for(int j=0; j<4; j++) {
            a[i][c-1+j]=b[i][j];
        }
    }
    int min=50;
    for(int j=c-1; j<c-1+4; j++) {
        int begin=-50,end;
        for(int i=0; i<19; i++) {
            if(i<4&&a[i][j]==1&&a[i+1][j]==0) {
                begin=i;
            } else if(i>3&&a[i][j]==0&&a[i+1][j]==1) {
                end=i;
                if(min>end-begin) {
                    min=end-begin;
                    break;
                }
            }
        }
    }
    for(int j=c-1; j<c-1+4; j++) {
        for(int i=0; i<4; i++) {
            a[i+min][j]+=a[i][j];
        }
    }
    for(int i=4; i<19; i++) {
        for(int j=0; j<10; j++) {
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_36792042/article/details/82381424