ccf2016042

#include <iostream>


using namespace std;


int main()
{
    int a[15][10];
    //= {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,1,0,0},{0,0,0,0,0,0,1,0,0,0},{0,0,0,0,0,0,1,0,0,0},{1,1,1,0,0,0,1,1,1,1},{0,0,0,0,1,0,0,0,0,0}};
    for(int i = 0; i < 15; i++){
        for(int j = 0; j < 10; j++){
            cin >> a[i][j];
        }
    }
    int b[4][4];
    //={{1,1,0,0},{0,1,1,0},{0,0,0,0},{0,0,0,0}};
   for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
           cin >> b[i][j];
        }
    }
    int initLocation=0;
    cin >> initLocation;
    int bLocation[4] = {5,5,5,5};
    for(int i = 0; i < 4; i++){//panduan mei yi lie
        for(int j = 3; j >= 0; j--){
                 //cout << j << endl;
        // cout << b[j][i] << endl;
            if(b[j][i] == 1){
                bLocation[i] = 4- j;//cong xia wang sahng shu di ji ge
                break;


            }
        }
    }


    int aLocation[4] = {16,16,16,16};
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 15; j++){
            if(a[j][i + initLocation-1] == 1){
                aLocation[i] = j + 1;//cong shang wang xia shu di ji ge
                break;
            }
        }
    }
     /*for(int i = 0; i < 4; i++){
        cout << bLocation[i] << " ";
    }
    cout << endl;
    for(int i = 0; i < 4; i++){
        cout << aLocation[i] << " ";
    }
    cout << endl;*/


    int minorder = 4;
    int min = INT_MAX;
    //cout <<"INT_MAX  "<< INT_MAX << endl;
    for(int i = 0; i < 4; i++){
        if(aLocation[i] != 5 && ((aLocation[i] + bLocation[i]) < min)){
            min = aLocation[i] + bLocation[i];
            minorder = i;//b[4-bLocation[minorder]][minorder]
            //cout <<"minorder  "<< minorder << endl;
        }
    }
    //a[minorder + initLocation - 1][aLocation[i]-1] = 1; 12
    //a[aLocation[i]-2][minorder + initLocation - 1] = 1; 0
    //b[4-bLocation[i]][minorder] 0
    //cout <<endl << minorder << endl;
    //cout << "4-bLocation[i]" << 4-bLocation[minorder]<< endl;
    //cout << "aLocation[i]-2" << aLocation[minorder]-2<< endl;
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            if(b[i][j] == 1){
                //a[aLocation[i]-1][minorder + initLocation - 1] = 1;
                //cout <<"4-bLocation[minorder]-aLocation[minorder]+2   "<< 4-bLocation[minorder]-aLocation[minorder]+2 << endl;


                 //cout <<"j+initLocation - 1   "<< j+initLocation -1<< endl;
                a[i - (4-bLocation[minorder]-aLocation[minorder]+2)][j+initLocation-1]=1;
            }
        }
    }




        for(int i = 0; i < 15; i++){
        for(int j = 0; j < 10; j++){
            cout << a[i][j] << " ";
        }
        cout << endl;
    }










    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值