代码:
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
using namespace std;
char a[10][1000];
int main()
{
for(int i = 0; i < 5; i++) {
gets(a[i]);
}
int Node[10];
int len = strlen(a[0]);
int result = 0;
int NoNode = 1; //判断是否为非数字字符的标记
for(int i = 0; i < len; i = i+4)
{
Node[0] = 0; //字符是否为0
if(a[0][i] == '*' && a[0][i+1] == '*' && a[0][i+2] == '*') Node[0]++;
if(a[1][i] == '*' && a[1][i+1] != '*' && a[1][i+2] == '*') Node[0]++;
if(a[2][i] == '*' && a[2][i+1] != '*' && a[2][i+2] == '*') Node[0]++;
if(a[3][i] == '*' && a[3][i+1] != '*' && a[3][i+2] == '*') Node[0]++;
if(a[4][i] == '*' && a[4][i+1] == '*' && a[4][i+2] == '*') Node[0]++;
Node[1] = 0; //判断字符是否为1 ,后面以此类推
if(a[0][i] != '*' && a[0][i+1] != '*' && a[0][i+2] == '*') Node[1]++;
if(a[1][i] != '*' && a[1][i+1] != '*' && a[1][i+2] == '*') Node[1]++;
if(a[2][i] != '*' && a[2][i+1] != '*' && a[2][i+2] == '*') Node[1]++;
if(a[3][i] != '*' && a[3][i+1] != '*' && a[3][i+2] == '*') Node[1]++;
if(a[4][i] != '*' && a[4][i+1] != '*' && a[4][i+2] == '*') Node[1]++;
Node[2] = 0;
if(a[0][i] == '*' && a[0][i+1] == '*' && a[0][i+2] == '*') Node[2]++;
if(a[1][i] == ' ' && a[1][i+1] == ' ' && a[1][i+2] == '*') Node[2]++;
if(a[2][i] == '*' && a[2][i+1] == '*' && a[2][i+2] == '*') Node[2]++;
if(a[3][i] == '*' && a[3][i+1] == ' ' && a[3][i+2] != '*') Node[2]++;
if(a[4][i] == '*' && a[4][i+1] == '*' && a[4][i+2] == '*') Node[2]++;
Node[3] = 0;
if(a[0][i] == '*' && a[0][i+1] == '*' && a[0][i+2] == '*') Node[3]++;
if(a[1][i] == ' ' && a[1][i+1] == ' ' && a[1][i+2] == '*') Node[3]++;
if(a[2][i] == '*' && a[2][i+1] == '*' && a[2][i+2] == '*') Node[3]++;
if(a[3][i] == ' ' && a[3][i+1] == ' ' && a[3][i+2] == '*') Node[3]++;
if(a[4][i] == '*' && a[4][i+1] == '*' && a[4][i+2] == '*') Node[3]++;
Node[4] = 0;
if(a[0][i] == '*' && a[0][i+1] == ' ' && a[0][i+2] == '*') Node[4]++;
if(a[1][i] == '*' && a[1][i+1] == ' ' && a[1][i+2] == '*') Node[4]++;
if(a[2][i] == '*' && a[2][i+1] == '*' && a[2][i+2] == '*') Node[4]++;
if(a[3][i] == ' ' && a[3][i+1] == ' ' && a[3][i+2] == '*') Node[4]++;
if(a[4][i] == ' ' && a[4][i+1] == ' ' && a[4][i+2] == '*') Node[4]++;
Node[5] = 0;
if(a[0][i] == '*' && a[0][i+1] == '*' && a[0][i+2] == '*') Node[5]++;
if(a[1][i] == '*' && a[1][i+1] != '*' && a[1][i+2] != '*') Node[5]++;
if(a[2][i] == '*' && a[2][i+1] == '*' && a[2][i+2] == '*') Node[5]++;
if(a[3][i] == ' ' && a[3][i+1] == ' ' && a[3][i+2] == '*') Node[5]++;
if(a[4][i] == '*' && a[4][i+1] == '*' && a[4][i+2] == '*') Node[5]++;
Node[6] = 0;
if(a[0][i] == '*' && a[0][i+1] == '*' && a[0][i+2] == '*') Node[6]++;
if(a[1][i] == '*' && a[1][i+1] != '*' && a[1][i+2] != '*') Node[6]++;
if(a[2][i] == '*' && a[2][i+1] == '*' && a[2][i+2] == '*') Node[6]++;
if(a[3][i] == '*' && a[3][i+1] == ' ' && a[3][i+2] == '*') Node[6]++;
if(a[4][i] == '*' && a[4][i+1] == '*' && a[4][i+2] == '*') Node[6]++;
Node[7] = 0;
if(a[0][i] == '*' && a[0][i+1] == '*' && a[0][i+2] == '*') Node[7]++;
if(a[1][i] == ' ' && a[1][i+1] == ' ' && a[1][i+2] == '*') Node[7]++;
if(a[2][i] == ' ' && a[2][i+1] == ' ' && a[2][i+2] == '*') Node[7]++;
if(a[3][i] == ' ' && a[3][i+1] == ' ' && a[3][i+2] == '*') Node[7]++;
if(a[4][i] == ' ' && a[4][i+1] == ' ' && a[4][i+2] == '*') Node[7]++;
Node[8] = 0;
if(a[0][i] == '*' && a[0][i+1] == '*' && a[0][i+2] == '*') Node[8]++;
if(a[1][i] == '*' && a[1][i+1] == ' ' && a[1][i+2] == '*') Node[8]++;
if(a[2][i] == '*' && a[2][i+1] == '*' && a[2][i+2] == '*') Node[8]++;
if(a[3][i] == '*' && a[3][i+1] == ' ' && a[3][i+2] == '*') Node[8]++;
if(a[4][i] == '*' && a[4][i+1] == '*' && a[4][i+2] == '*') Node[8]++;
Node[9] = 0;
if(a[0][i] == '*' && a[0][i+1] == '*' && a[0][i+2] == '*') Node[9]++;
if(a[1][i] == '*' && a[1][i+1] == ' ' && a[1][i+2] == '*') Node[9]++;
if(a[2][i] == '*' && a[2][i+1] == '*' && a[2][i+2] == '*') Node[9]++;
if(a[3][i] == ' ' && a[3][i+1] == ' ' && a[3][i+2] == '*') Node[9]++;
if(a[4][i] == '*' && a[4][i+1] == '*' && a[4][i+2] == '*') Node[9]++;
int j;
for(j = 0; j < 10; j++) {
if(Node[j] == 5) {
result = result*10+j;
break;
}
}
if(j == 10) NoNode = 0;
}
if(NoNode == 0) printf("BOOM!!\n");
else if(result%6 == 0) printf("BEER!!\n");
else printf("BOOM!!\n");
return 0;
}