- **C**
(*http://www.go4expert.com/forums/c/*)

- - **Neigbour array elements**
(*http://www.go4expert.com/forums/neigbour-array-elements-t16896/*)

Neigbour array elementsI'm dealing with 2 dimensional arrays and i couldn't figure out how to do this:
for example assume we have a 4x4 matrix, and there is a predefined number k(which is between 0 and 128).well let's declare the array as a[i][j]. for example if the value of a[i][j]>k and if the neigbors of a[i][j]<=k,it will count 1. but when a[i][j]>k , if one or more of a[i][j]'s neigbors is also bigger than k ,it will also count 1. I mean,for example if a[0][0]>k,a[0][1]>k and a[1][1]>k this whole 3 cell count as 1. how can i make this? |

Re: Neigbour array elementsCode:
`#include<stdio.h>` |

Re: Neigbour array elementsAs I often say, try doing it yourself on paper. Write out (with the computer's help if necessary) 16 random numbers and see what the count would come to for varying values of k. This isn't a simple task and you're not going to solve it by starting to type out some code; you need to work out an algorithm first.
Once you've done it a few times on paper you should start getting the hang of it and you can then start thinking about an algorithm for the computer to follow. So let's say we have Code:
`14 27 6 13` Hint: if I were tasked with solving this, I'd use a second array with the same dimensions as the first. |

All times are GMT +5.5. The time now is 21:10. |