I have four arrays as input, then used it in a function that result an output. Then I sorted the output array. Next step, I want to find the index and the value of the input array that resulted the sorted array. I keep getting the wrong result.
Here my (part of) code (forgive me for my poor codes;

for (i=0; i<size2; i++){               
    for (l=0;l<point3[i];l++){  
       for (a=0;a<b[i][l];a++){
            gradient [i][l][a]=(S[i][l][a]-Cy[i][l])/(R[i][l][a]-Cx[i][l]);
       }
     //To sort the output
       for (a=0;a<b[i][l]-1;a++){
          for (d=a+1;d<b[i][l];d++){  
            if (gradient[i][l][a]>=gradient[i][l][d]){
                  temp=gradient[i][l][a];                        
                   gradient[i][l][a]=gradient[i][l][d];
                    gradient[i][l][d]=temp;                    
              }
           } 
         }
      }
 
// To search the "R and S' index and value"
 for (i=0; i<size2; i++){               
    for (l=0;l<point3[i];l++){  
       for (a=0;a<b[i][l];a++){
            for (k=0;k<b[i][j];k++){        
                if (fabs((S[i][l][a]-Cy[i][l])/(R[i][l][a]-Cx[i][l]))==gradient[i][l][a]){
                   printf ("[%d][%d][%d]\t%f\t%f\n",i,l,k,R[i][l][k],S[i][l][k]);                   
                }                   
            }
         }
     } 
 }

The result I have is just R[1][1][3] and S[1][1][3];even though size2=4 and point3 is between 4 or 5. Why I keep getting this result? Is my loop incorrect or is it my if condition?
How can I fix it?
Thanks.

Salem commented: post == 1 && tags == true, well done! +31
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.