paste bin
Author
Language
C++
Plain text
Accesslog
Action script
Ada
Apache
Arduino
Armasm
Autohotkey
Awk
Bash
Basic
Brainfuck
C
Clojure
Cmake
C#
css
D
Delphi
Dockerfile
Erlang
Fortran
F#
Gauss
Go
Gradle
Graphql
Groovy
Haskell
Ini
Java
JavaScript
json
Julia
Kotlin
Lasso
LaTeX
Leaf
lisp
llvm
Lua
Makefile
Markdown
Mathematica
Matlab
Nginx
Objective-C
Ocaml
Oxygene
Perl
PgSQL
php
Powershell
Processing
Profile
Properties
Puppet
Purebasic
Python
Q
QML
R
Ruby
Rust
Scala
Scheme
Scilab
Shell
Smalltalk
SQL
Swift
Typescript
VB.NET
VB Script
Verilog
Vim
Wasm
x86asm
Xml
Xquery
Yaml
source code:
#include <cstdio> #include <cstring> #define MAXN 102 #define MAXM 102 int M,N; char bitmap[MAXN][MAXM]; char howManyMine(int x,int y) { int dx,dy,count; count=0; for(dx=-1;dx<=1;dx++) { for(dy=-1;dy<=1;dy++) { if(bitmap[x+dx][y+dy]=='*') { count+=1; } } } return '0'+count; } int main(void) { int index=0; int i,j; while(1) { scanf("%d%d",&N,&M); if(N==0 and M==0) break; memset(bitmap,'+',sizeof(char)*MAXM*MAXN); for(i=1;i<=N;i++) { getchar(); for(j=1;j<=M;j++) scanf("%c",&bitmap[i][j]); } } for(i=1;i<=N;i++) { for(j=1;j<=M;j++) { if(bitmap[i][j]=='.') { bitmap[i][j]=howManyMine(i,j); } } } if(index>0) printf("\n"); printf("Field #%d:\n",index+1); index++; for(i=1;i<=N;i++) { for(j=1;j<=M;j++) { printf("%c",bitmap[i][j]); } printf("\n"); } } return 0; }
comment: