Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Got Part A, so just answer Part B. Need it as soon as possbile. 3.) The grid_t t

ID: 3570701 • Letter: G

Question

Got Part A, so just answer Part B. Need it as soon as possbile.

3.) The grid_t type below can be used to store a width by height grid of altitudes. Adjacent grid points on the x (first) axis are separated by dx meters. Similarly, adjacent grid points on the y axis (second) are separated by dy meters. typedef struct { double dx, dy; double alt[MAX][MAX]; int width, height; } gridt; Write a function that creates a new grid_t struct and returns a pointer to it. Its parameters should include the data needed to initialize the values of the structure. It should also zero out the altitudes before returning. (10 pts) grid_t new (double dx, double dy, int w, int h){ grid_rptr = (grid_t')malloc(sizeof(grid_t)); ptr->dx = dx; ptr->dy = dy; ptr->width = w; ptr->height=h; int i,j; for(i=0; i

Explanation / Answer

typedef struct
{
   double dx,dy;
   double alt[MAX][MAX];
   int width,height;
}grid_t;

double func(grid_t g){
   int i,j,maxi,maxj;
   double max=g->alt[0][0];
   for(i=0;i<w;i++)
      for(j=0;j<h;j++){
          if(g->alt[i][j]>max)
              max=g->alt[i][j];
              maxi=i;
              maxj=j;
      }
     
return sqrt((0-i)*(0-i)+(j-h+1)*(j-h-1));


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote