標題:
[轉貼]
賓果
[打印本頁]
作者:
neilgboy
時間:
昨天 15:54
標題:
賓果
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(){
int n , m ;
scanf("%d",&n);
scanf("%d",&m);
int borad[15][m][m];
int diagonal[n][2];
int bingo[15][2][m];
for (int p = 0; p < n; p++) {
for (int col = 0 ; col < m; col++) {
for (int row = 0; row < m; row++) {
scanf("%d",&borad[p][col][row]);
}
}
}
memset(diagonal, 0, sizeof(diagonal));
memset(bingo, 0, sizeof(bingo));
int number_list[m*m];
for (int i = 0; i < m * m ; i++) {
scanf("%d",&number_list[i]);
}
printf("\n");
int flag_bingo = 0 ;
int flag_fast = 0 ;
int first = 1 ;
for (int number = 0; number < m * m && flag_bingo == 0 ; number++) {
for (int p = 0; p < n ; p++) {
flag_fast = 0 ;
for (int col = 0; col < m && flag_fast == 0; col++) {
for (int row = 0; row < m && flag_fast == 0; row++) {
if (number_list[number] == borad[p][col][row]) {
bingo[p][0][row]++ ;
bingo[p][1][col]++ ;
if (col == row) {
diagonal[p][0]++;
}
if (col + row == m - 1) {
diagonal[p][1]++;
}
if (bingo[p][0][row] == m || bingo[p][1][col] == m || diagonal[p][0] == m || diagonal[p][1] == m ) {
if (first) {
printf("%d",number_list[number]);
printf(" %d",p);
first = 0 ;
flag_bingo = 1 ;
}
else
printf(" %d",p);
}
}
}
}
}
}
return 0 ;}
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)