Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- // Matricata treba da ja smenite, taka shto novata vrednost na sekoj element ke bide zbirot na negovite sosedi.
- int main()
- {
- int n,m,i,j,a[100][100];
- scanf("%d%d", &n, &m);
- for(i=0;i<n+2;i++)
- {
- for(j=0;j<m+2;j++)
- {
- a[i][j] = 0;
- }
- }
- for(i=1;i<n+1;i++)
- {
- for(j=1;j<m+1;j++)
- {
- scanf("%d", &a[i][j]);
- }
- }
- int b[100][100];
- for(i=1;i<n+1;i++)
- {
- for(j=1;j<m+1;j++)
- {
- b[i][j] = a[i-1][j] + a[i+1][j] + a[i][j-1] + a[i][j+1];
- }
- }
- for(i=1;i<n+1;i++)
- {
- for(j=1;j<m+1;j++)
- {
- printf("%d", b[i][j]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement