HELP ME TO MAKE PSEUDOCODE OF THIS CODE (C) #include int ec_dist_sq(int x1,int y1,int x2,int y2) { return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); } int min(int x,int y) { return x>y? y:x; } int main() { int...



HELP ME TO MAKE PSEUDOCODE OF THIS CODE (C)




#include
int ec_dist_sq(int x1,int y1,int x2,int y2)
{
   return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
int min(int x,int y)
{
   return x>y? y:x;
}
int main()
{
   int n, i, j;
   scanf("%d",&n);
   int mat[n][n];
   for(i=0;i<>
   {
       for(j=0;j<>
       {
           scanf("%d",&mat[i][j]);
       }
   }
   int centroid_x = n/2;
   int centroid_y = n/2;
   int centroid_value=mat[centroid_x][centroid_y];
   int min_distance = 9999;
   for(i=0;i<>
   {
       for(j=0;j<>
       {
           if((i!=centroid_x || j!=centroid_y) && centroid_value==mat[i][j])
           {
               min_distance = min(min_distance,ec_dist_sq(i,j,centroid_x,centroid_y));
               printf("%d %d %d\n",i,j,ec_dist_sq(i,j,centroid_x,centroid_y));
           }
       }
   }
   int found = 0;
   printf("Nearest elements is at:");
   for(i=0;i<>
   {
       for(j=0;j<>
       {
           if(centroid_value==mat[i][j] && ec_dist_sq(i,j,centroid_x,centroid_y)==min_distance)
           {
               printf("%d,%d\n",i,j);
               found = 1;
           }
       }
   }
   if(!found)
       printf("no nearest element");
   return 0;
}



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here