I can run the program but it doesn't goes well at the end ..
it didn't show where is the brightest point at ..
Code:
#include<stdio.h>
#define x_dim 5
#define y_dim 5
int main( void )
{
int aiRawdata[ x_dim ][y_dim];
int aiMaxCoords[ x_dim * y_dim][2];
int icurrentmax;
int inumbrightest;
int index1, index2, iloop;
icurrentmax = -1;
inumbrightest = 0;
for ( index1=0; index1 < x_dim; ++index1 ) {
for (index2 =0; index2 < y_dim; ++index2) {
printf("Enter the brightness data coordinate [%d][%d] :" , index1, index2 );
scanf("%d", &aiRawdata [index1][index2] );
if (aiRawdata [index1][index2] == icurrentmax)
{
aiMaxCoords[inumbrightest][0] = index1;
aiMaxCoords[inumbrightest][1] = index2;
inumbrightest++;
}
else if (aiRawdata [index1][index2] > icurrentmax);
{
icurrentmax = aiRawdata[index1][index2];
inumbrightest = -1;
aiMaxCoords[0][0] = index1;
aiMaxCoords[0][1] = index2;
}
}
}
printf("there were %d pixels with max brightest %d as follows:\n", inumbrightest, icurrentmax);
for (iloop =0; iloop < inumbrightest; ++iloop) {
printf("Pixel at [%d][%d]\n", aiMaxCoords[iloop][0], aiMaxCoords [iloop][1]);
}
return (0);
}
can someone tell me the error ?
thank you !