1 条题解
-
0
C :
int n; char g[100][100]; main() { int i, j, k, x, y, z, dx, dy; char ch, ch2, pl; scanf( " %d", &n ); for( i = 0; i < n; i++ ) for( j = 0; j < n; j++ ) g[i][j] = '.'; pl = 'X'; for(;;) { scanf( " %c", &ch ); switch( ch ) { case 'Q': printf( "TIE GAME\n" ); return 0; case 'L': x = 0; dy = 0; dx = 1; scanf( " %d", &y ); y--; break; case 'R': x = n-1; dy = 0; dx = -1; scanf( " %d", &y ); y--; break; case 'T': y = 0; dx = 0; dy = 1; scanf( " %d", &x ); x--; break; case 'B': y = n-1; dx = 0; dy = -1; scanf( " %d", &x ); x--; break; } ch = pl; for(;;) { ch2 = ch; ch = g[x][y]; g[x][y] = ch2; x += dx; y += dy; if( ch == '.' || x == n || y == n || x < 0 || y < 0 ) break; } x = 0; for( i = 0; i < n; i++ ) { for( j = 0; j < n; j++ ) if( g[i][j] != 'X' ) break; if( j == n ) x++; for( j = 0; j < n; j++ ) if( g[i][j] != 'O' ) break; if( j == n ) x--; for( j = 0; j < n; j++ ) if( g[j][i] != 'X' ) break; if( j == n ) x++; for( j = 0; j < n; j++ ) if( g[j][i] != 'O' ) break; if( j == n ) x--; } if( x > 0 ) { printf( "X WINS\n" ); return 0; } else if( x < 0 ) { printf( "O WINS\n" ); return 0; } pl = (pl == 'X') ? 'O' : 'X'; } }
- 1
信息
- ID
- 1033
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者