博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NEU 1515 Play with bear kid
阅读量:4620 次
发布时间:2019-06-09

本文共 2566 字,大约阅读时间需要 8 分钟。

1515: Play whit bear kid

时间限制: 1 Sec  内存限制: 128 MB
提交: 3  解决: 2

题目描述

Happy Spring Festival everyone! Many relatives will visit your house, of course they have bear kids. Now you are playing chess with a bear kid.

It's really terrible. You have a 3*3 chessboard, bear kid puts 0s and you put 1s while the empty positions are '.' . The rule is that one whose 
chess pieces are in a line horizontally, vertically or diagonally will win.

输入

There are several cases.

For each case, there is a 3*3 chessboard and the chess pieces have been put.

输出

You should judge whether someonw has won or not. 

If the bear kid win, output "BEAR KID". 
If you win, output "YOU".
Output "NO BODY" in other cases.

We guarantee you and bear kid won't win at the same time, and the number of 0s and 1s may be not the same.

样例输入

000......

样例输出

BEAR KID

提示

 

来源

 

东北大学二月月赛第一题

简单的模拟题,分别判断同一行,同一列,对角线和反对角线四种情况就可以了。

 

1 #include
2 #include
3 4 using namespace std; 5 6 char board[4][4]; 7 8 int main() 9 {10 while(cin>>board[1][1])11 {12 int result = 0; //result=0:NO BODY; result=1:YOU; result=2:BEAR KID13 for(int i = 1; i <= 3; i++)14 for(int j = 1; j <= 3; j++)15 {16 if(i == 1 && j == 1)17 continue;18 cin>>board[i][j];19 }20 for(int i = 1; result == 0 && i <= 3; i++)21 {22 if(board[i][1] == board[i][2] && board[i][2] == board[i][3])23 {24 if(board[i][1] == '1')25 result = 1;26 else if(board[i][1] == '0')27 result = 2;28 }29 }30 for(int j = 1; result == 0 && j <= 3; j++)31 {32 if(board[1][j] == board[2][j] && board[2][j] == board[3][j])33 {34 if(board[1][j] == '1')35 result = 1;36 else if(board[1][j] == '0')37 result = 2;38 }39 }40 if(board[1][1] == board[2][2] && board[2][2] == board[3][3])41 if(board[1][1] == '1')42 result = 1;43 else if(board[1][1] == '0')44 result = 2;45 if(board[1][3] == board[2][2] && board[2][2] == board[3][1])46 if(board[1][3] == '1')47 result = 1;48 else if(board[1][3] == '0')49 result = 2;50 if(result == 0)51 cout<<"NO BODY"<
[C++]

 

 

转载于:https://www.cnblogs.com/lzj-0218/p/4304547.html

你可能感兴趣的文章
搜索旋转排序数组 II
查看>>
20、docker swarm
查看>>
psp工具软件前景与范围文档
查看>>
day06-三元表达式
查看>>
C# DateTime.Now详细用法
查看>>
Php中"{}"大括号的用法总结(转)
查看>>
JavaScript内存优化
查看>>
BZOJ1059: [ZJOI2007]矩阵游戏(二分图匹配)
查看>>
P3385 【模板】负环
查看>>
URI、URL 和 URN的区别
查看>>
根据表达式序列(前缀、中缀、后缀)构建表达式树
查看>>
mysql性能优化
查看>>
【SqlServer系列】语法定义符号解析
查看>>
Color Length UVA - 1625
查看>>
TLS/SSL
查看>>
webpack笔记(4)对图片的处理
查看>>
如果判断一个dom 对像?
查看>>
搜索引擎的反作弊问题
查看>>
nginx lua 01
查看>>
计算机网络 chapter 8 因特网上的音频/视频服务
查看>>