当前位置:   article > 正文

L - OOXX Game FZU - 2151 思维题 字符串的处理_hentai game

hentai game

Fat brother and Maze are playing a kind of special (hentai) game on an NM board (N rows, M columns). At the beginning, there are NM coins in this board with two symbol “O” or “X”. Then they take turns to choose a grid with symbol “O” and change it into “X”. The game ends when all the symbols in the board are “X”, and the one who cannot play in his (her) turns loses the game. Fat brother and Maze like this kind of OOXX game very much and play it day and night. They don’t even need a little rest after each game!

Here’s the problem: Who will win the game if both use the best strategy? You can assume that Maze always goes first.

Input
The first line of the date is an integer T, which is the number of the text cases.

Then T cases follow, each case contains two integers N and M indicate the size of the board. Then goes N line, each line with M character shows the state of the board.

1 <= T <=100, 1 <= n <=100, 1 <= m <=100

Output
For each case, output the case number first, and then output the winner’s name, either Fat brother or Maze. See the sample input and output for more details.

Sample Input
3
1 4
OXXX
2 4
OOXX
OOXX
1 2
XX
Sample Output
Case 1: Maze
Case 2: Fat brother
Case 3: Fat brother
思路:判断奇偶即可。
字符数组处理

#include<stdio.h>
#include<iostream>
using namespace std;
char a[110];
int main()
{
    int t;
    int ans=0;
    scanf("%d",&t);
    while(t--)
    {
        int n,m;
        int i;
        scanf("%d%d",&n,&m);
        getchar();
        int cnt=0;

        for(i=1;i<=n*m;i++)
            {scanf("%c",&a[i]);
            if(a[i]=='O')
                cnt++;
           if(i%m==0)
            getchar();
            }
            printf("Case %d: ",++ans);
            if(cnt%2==0)
                printf("Fat brother\n");
            else
                printf("Maze\n");
    }
    return 0;
}


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

字符串数组

#include<stdio.h>
char a[110][110];
int main()
{
    int t;
    int ans=1;
    scanf("%d",&t);
    while(t--)
    {
        int i,n,m,j;
        int cnt=0;
        scanf("%d%d",&n,&m);
        for(i=0;i<n;i++)
            scanf("%s",a[i]);//这里用i储存行。
        for(i=0;i<n;i++)
            for(j=0;j<m;j++)
            if(a[i][j]=='O')
                cnt++;
                printf("Case %d: ",ans++);
            if(cnt%2==0)
                printf("Fat brother\n");
            else printf("Maze\n");

    }
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/59453
推荐阅读
相关标签
  

闽ICP备14008679号