Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7506835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:21:47+00:00 2026-05-29T22:21:47+00:00

I need to create a 375 x 375 grid in c, and I need

  • 0

I need to create a 375 x 375 grid in c, and I need to create a grid of 25 (5×5) poles that will be spaced 75 (375/5) grid points apart. I will then need to calculate for any given grid point how close it is to a pole. This is not a visual grid, but I’m still having trouble wrapping my head on how to create this grid set-up programmatically. So far, I’v created a “Point” struct that consist of two ints x and y:

typedef struct{
    int x, y;
}Point;

I then define my grid as a 375×375 Point array and set the x and y values asi and jrespectfully, in a nested for loop. However I’m having a hard time figuring out how to create the pole position array. Should it be a 5×5 array with the x and y values set as i*15 andj*15? If so then how would I use the two 2D arrays together.I couldn’t do a calculation like this obviously:

        for(i = 0; i < 375; i ++){
        for(j = 0; j<375; j++){
            distance(polePos[i][j], grid[i][j]);
        }
    }

but If I make it a 375×375 array, then how do I designate the pole position?
Am I on the right track? Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:21:50+00:00Added an answer on May 29, 2026 at 10:21 pm

    You didn’t specify at which column-/row-indices the poles should be placed so in the following i place them 75-apart starting at 0, so the poles are at column-/row-indices 0, 75, 150, 225, 300, 375 (so 6 poles). It might not be precisely what you had in mind but it will get you started.

    #include "stdio.h"
    #include "math.h"
    double distance(double x, double y, double grid) {
        x = fmod(x, grid);
        y = fmod(y, grid); // <- these modulos makes us treat every interval like the interval 0...grid
        double dx = grid/2 - fabs(x -grid/2);
        double dy = grid/2 - fabs(y -grid/2);    
        //printf("%3u %3u %f %f \n", x, y, dx, dy);
        return sqrt(dx*dx+dy*dy);
    }
    int main(void) {
        int i; int j;
        double grid[375][375];
          for(i = 0; i < 375; i ++){
            for(j = 0; j<375; j++){
                grid[i][j] = distance(i, j, 75);
                printf("%3u %3u %f\n", i, j, grid[i][j]);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a script that will log into an authenticated page and
I need to create a program that will communicate with other programs on the
I need create a stored proc that will return a list of a code,
Need to create a custom DNS name server using C which will check against
I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create a backup of a SQL Server 2005 Database that's only
I need create a SQL Server stored procedure that does the following: Take an
How create a link_to_remote in a jQuery script where url need a parameter that
I need create some fork for project. So for some beans that depends from
I need create custom dialog and put JPanel into it. Is it possible?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.