Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(){
- int l,n,i,j;
- scanf("%d%d",&l,&n);
- int m[100][100];
- for(i=0;i<l;i++)
- for(j=0;j<n;j++)
- scanf("%d",&m[i][j]);
- for(i=0;i<l;i++)
- {
- for(j=0;j<n;j++)
- {
- if(m[i][j]==0)
- {
- int br=0;
- if(i!=0)
- br+=m[i-1][j];
- if(i!=l-1)
- br+=m[i+1][j];
- if(j!=0)
- br+=m[i][j-1];
- if(j!=n-1)
- br+=m[i][j+1];
- if(i!=0&&j!=0)
- br+=m[i-1][j-1];
- if(i!=l-1 && j!=0)
- br+=m[i+1][j-1];
- if(i!=0 && j!=n-1)
- br+=m[i-1][j+1];
- if(i!=l-1 && j!=n-1)
- br+=m[i+1][j+1];
- printf("%d ",br);
- }
- else
- {
- printf("%c ",'*');
- }
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement