> 2 dim array in C?

2 dim array in C?

Posted at: 2014-12-18 
If you are hard-coding the array to be explicitly 7 x 7, then the middle element will be [3][3].

First compare the middle element with any other element, say [0][0].

If they are equal, you can immediately return 0, since this eliminates the condition that the middle term is different from the rest.

If not, then you can scan the entire array to check the equality of all the other members do not equal [3][3].

Use nested for loops to traverse the rows and then columns.

compare each element to [3][3].

Include a special condition in which the middle element is skipped.

If any one member is equal to the middle member, then return 0.

If the for loops finish without returning prematurely, then you return 1.

suppose you have an array 7x7 and in that array there are random numbers 0's and 1's.

You want to return 1 to the main if:

all elements in the array are equal (has the same number) except the middle point in the array.

else return 0.

How do you check if all the elements in the array have the same number except the one in the middle?