Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <string.h>
- using namespace std;
- char matrix[105][105], temp[105];
- int main(){
- int n, m, c=1;
- bool space = true;
- while(cin >> n){
- memset(matrix,0,sizeof(matrix));
- cin >> m;
- if(n==0 && m==0)
- return 0;
- for(int i=0; i<n; i++){
- gets(temp);
- cin >> matrix[i];
- }
- if(c>1)
- cout << endl;
- cout << "Field #" << c << ":" << endl;
- int bomb;
- for(int j=0; j<n; j++){
- for(int k=0; k<m; k++){
- if(matrix[j][k]=='*')
- cout << "*";
- else{
- bomb=0;
- if(matrix[j-1][k-1]=='*')
- bomb++;
- if(matrix[j-1][k]=='*')
- bomb++;
- if(matrix[j-1][k+1]=='*')
- bomb++;
- if(matrix[j][k-1]=='*')
- bomb++;
- if(matrix[j][k+1]=='*')
- bomb++;
- if(matrix[j+1][k-1]=='*')
- bomb++;
- if(matrix[j+1][k]=='*')
- bomb++;
- if(matrix[j+1][k+1]=='*')
- bomb++;
- cout << bomb;
- }
- }
- cout << endl;
- }
- c++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment