UVa Problem Solution: 10189 - Minesweeper
来源:互联网 发布:淘宝店铺登录名 编辑:程序博客网 时间:2024/04/25 18:04
Straight forward method. I did not work out a funnier solution.
Code:
- /*************************************************************************
- * Copyright (C) 2008 by liukaipeng *
- * liukaipeng at gmail dot com *
- *************************************************************************/
- /* @JUDGE_ID 00000 10189 C "Minesweeper" */
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <strings.h>
- #define MAX 102
- int around(int mat[][MAX], int n, int m)
- {
- return mat[n-1][m-1] + mat[n-1][m] + mat[n-1][m+1]
- + mat[n][m-1] + mat[n][m+1]
- + mat[n+1][m-1] + mat[n+1][m] + mat[n+1][m+1];
- }
- int main(int argc, char *argv[])
- {
- #ifndef ONLINE_JUDGE
- char in[256];
- char out[256];
- strcpy(in, argv[0]);
- strcat(in, ".in");
- strcpy(out, argv[0]);
- strcat(out, ".out");
- close(0);
- open(in, O_RDONLY);
- close(1);
- open(out, O_WRONLY | O_CREAT, 0600);
- #endif
- int mat[MAX][MAX];
- int n, m, i, j, f = 1;
- char c;
- for (scanf("%d %d", &n, &m); n != 0 && m != 0; scanf("%d %d", &n, &m)) {
- if (f != 1)
- putchar('/n');
- bzero(mat, MAX*MAX*sizeof(int));
- c = getchar();
- for (i = 1; i <= n; ++i) {
- for (j = 1; j <= m; ++j) {
- c = getchar();
- if (c == '*') mat[i][j] = 1;
- else if (c == '.') mat[i][j] = 0;
- }
- c = getchar();
- }
- printf("Field #%d:/n", f++);
- for (i = 1; i <= n; ++i) {
- for (j= 1; j <= m; ++j) {
- if (mat[i][j] == 1) putchar('*');
- else printf("%d", around(mat, i, j));
- }
- putchar('/n');
- }
- }
- return 0;
- }
- UVa Problem Solution: 10189 - Minesweeper
- UVa Problem 10189 Minesweeper (扫雷)
- UVa Problem 10189 Minesweeper (扫雷)
- UVa Problem 10189 Minesweeper (扫雷)
- UVa 10189 Problem: Minesweeper (PC 110102)
- Uva 10189 - Minesweeper
- uva 10189 - Minesweeper
- UVa 10189 - Minesweeper
- uva 10189 - Minesweeper
- uva 10189 Minesweeper
- UVa 10189 Minesweeper (模拟)
- UVa 10189 Minesweeper
- UVa 10189 Minesweeper
- UVa 10189 - Minesweeper
- uva Minesweeper 10189
- uva 10189 Minesweeper
- UVA 10189 Minesweeper
- UVA 10189 -Minesweeper
- project 5 中问题详记(spring)
- Expert one on one J2EE development without EJB 摘要(6)
- Hibernate常见的20个问题
- 什么是程序员的优秀品质?
- BASIS Level..
- UVa Problem Solution: 10189 - Minesweeper
- script.aculo.us概述
- 血型最奥妙剖析
- 关于部署完asp.net程序后不能访问页面也不能连接数据库的问题
- 北京名吃地址
- FLEX新(人)问题
- 转摘个关于bstr的。
- 使用 JSON 进行数据传输
- script.aculo.us代码分析(一)