其他分享
首页 > 其他分享> > The Pilots Brothers' refrigerator

The Pilots Brothers' refrigerator

作者:互联网

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int mem[4][4];//用于储存翻转次数,如果是偶数,则相当于没有翻转

int main(){
    char ch;
    for (int x = 0; x<4; x++){//按sample的顺序,x代表纵行,y是横列
        for (int y = 0; y <= 4; y++){
            ch = getchar();
            if (ch == '+'){
                for (int i = 0; i<4; i++){
                    mem[i][y]++;
                }
                for (int j = 0; j<4; j++){
                    mem[x][j]++;
                }
                mem[x][y]++;
            }
        }
    }
    int ans = 0;
    string str;
    for (int x = 0; x<4; x++){
        for (int y = 0; y<4; y++){
            int index = mem[x][y];
            if ((index / 2) * 2 != index){            //表明是奇数,则是需要点击一次
                ans++;
                str += ('1' + x);
                str += 32;
                str += '1' + y;
                str += '\n';
            }
        }
    }
    printf("%d\n", ans);
    cout << str;
    return 0;
}

 

标签:std,main,Pilots,Brothers,int,include,refrigerator,翻转
来源: https://www.cnblogs.com/ALINGMAOMAO/p/11197374.html