1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sladkih [1.3K]
3 years ago
6

In this exercise, you will write a Point structure that represents a space in two-dimensional space. This Point should have both

x and y elds (please use these exact names). You will also write three functions for dealing with Points; freadPoint, manhattanDistance, and euclideanDistance. freadPoint should take in a FILE handle and a Point (by reference) that it will initialize; it should not do any prompting. It will return true if it succeeds in reading a point and false if it fails. Each point will be a line in the le, with the x and y coordinates separated by spaces. A sample input le, point29.txt has been included. The manhattanDistance function will take two Points and compute the Manhattan distance (city block distance) between them, which is the distance that you would travel if you are restricted to walking parallel to either the x or y axes. Likewise, the euclideanDistance function will take two Points and compute the Euclidean distance (straight-line distance) between them. Neither function prints anything; they simply return a value. Your main function will prompt the user to enter two points and then display the Manhattan and Euclidean distances. You should call each of your functions (using stdio as a parameter to freadPoint) to do so. You may want to use the fabs and sqrt functions to help you with this assignment

Engineering
1 answer:
Afina-wow [57]3 years ago
8 0

Answer:

Check the explanation

Explanation:

Points to consider:

We need to take the input from the user

We need to find the manhatan distance and euclidian using the formula

(x1, y1) and (x2, y2) are the two points

Manhattan:

|x_1 - x_2| + |y_1 - y_2|

Euclidian Distance:

\sqrt{(x1 - yl)^2 + (x2 - y2)^2)}

Code

#include<stdio.h>

#include<math.h>

struct Point{

  int x, y;

};

int manhattan(Point A, Point B){

  return abs(A.x - B.x) + abs(A.y- B.y);

}

float euclidean(Point A, Point B){

  return sqrt(pow(A.x - B.x, 2) + pow(A.y - B.y, 2));

}

int main(){

  struct Point A, B;

  printf("Enter x and Y for first point: ");

  int x, y;

  scanf("%d%d", &x, &y);

  A.x = x;

  A.y = y;

  printf("Enter x and Y for second point: ");

  scanf("%d%d", &x, &y);

  B.x = x;

  B.y = y;

  printf("Manhattan Distance: %d\n", manhattan(A, B));

  printf("Euclidian Distance: %f\n", euclidean(A, B));

 

}

Sample output

You might be interested in
Sinks must be used for the correct intended purpose to prevent
irakobra [83]

Answer:

... spilling water or getting anything cascading onto the floor

8 0
2 years ago
A step-down transformer (turns ratio = 1:7) is used with an electric train to reduce the voltage from the wall receptacle to a v
SOVA2 [1]

Answer:

wait lemme check it out

Explanation:

6 0
3 years ago
what i the maximum flow rate of glycerine at 20C in a 10cm diameter pipe that can be assumed to remain laminar
ELEN [110]

Answer: tube flow

Explanation:

7 0
2 years ago
The best saw for cutting miter joints is the
ZanzabumX [31]

Answer:

The best saw for cutting miter joints is the backsaw.

Add-on:

i hope this helped at all.

6 0
2 years ago
Should the ship breaking business continue why or why not?
Dmitry [639]

Answer:

Ship-breaking or ship demolition is a type of ship disposal involving the breaking up of ships for either a source of parts, which can be sold for re-use, or for the extraction of raw materials, chiefly scrap. It may also be known as ship dismantling, ship cracking, or ship recycling. Modern ships have a lifespan of 25 to 30 years before corrosion, metal fatigue and a lack of parts render them uneconomical to operate.[1] Ship-breaking allows the materials from the ship, especially steel, to be recycled and made into new products. This lowers the demand for mined iron ore and reduces energy use in the steel making process. Fixtures and other equipment on board the vessels can also be reused. While ship-breaking is sustainable, there are concerns about the use of poorer countries without stringent environmental legislation. It is also labor-intensive, and considered one of the world's most dangerous industries.[2]

In 2012, roughly 1,250 ocean ships were broken down, and their average age was 26 years.[3][4] In 2013, the world total of demolished ships amounted to 29,052,000 tonnes, 92% of which were demolished in Asia. As of January 2020, India has the largest global share at 30%;[5] followed by Bangladesh, China and Pakistan.[6] Alang, India currently has the world's largest ship graveyard,[5] followed by Chittagong Ship Breaking Yard in Bangladesh and Gadani in Pakistan.[6]

The largest sources of ships are states of China, Greece and Germany respectively, although there is a greater variation in the source of carriers versus their disposal.[7] The ship-breaking yards of India, Bangladesh, China and Pakistan employ 225,000 workers as well as providing many indirect jobs. In Bangladesh, the recycled steel covers 20% of the country's needs and in India it is almost 10%.[8]

As an alternative to ship-breaking, ships may be sunk to create artificial reefs after legally-mandated removal of hazardous materials, or sunk in deep ocean waters. Storage is a viable temporary option, whether on land or afloat, though all ships will be eventually scrapped, sunk, or preserved for museums.

6 0
3 years ago
Other questions:
  • Where are revolved sections placed in a print? A) in between break lines B) cutting planes are used to identify their locations
    12·1 answer
  • How an AK 47 gun was works​
    14·1 answer
  • A shaft is made of an aluminum alloy having an allowable shear stress of τallow = 100 MPa. If the diameter of the shaft is 100 m
    13·2 answers
  • A steel wire of diameter 2.000 mm and length 1.000 m is attached between two immovable supports.When the temperature is 60.00 Ce
    9·1 answer
  • A structural component in the shape of a flat plate 29.6 mm thick is to be fabricated from a metal alloy for which the yield str
    11·1 answer
  • A growing trend in urban design is the concept of a rooftop garden. If every building in a city were to install a rooftop garden
    13·1 answer
  • Why do organisms differ in their methods of reproduction?
    5·2 answers
  • The quantity of bricks required increases with the surface area of the wall, but the thickness of a masonry wall does not affect
    10·2 answers
  • A benefit to using the medium the author used in "Great Rock and Roll
    12·2 answers
  • Select the correct answer <br><br> What is the simplest definition of a manufacturing process?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!