Consider a square region in the first quadrant of the Cartesian plane whose bottom left and upper right corners have coordinates (0,0) and (100,100), respectively. A text file contains a sequence of rectangles, one per line, with sides parallel to the Cartesian axes. Each rectangle is identified by the x and y coordinates of the bottom left and upper right corners, reported with spaces as separators. The coordinates are integers between 0 and 100, with extremes included. Write a function:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
This is not a graded question so please don't disregard it as if it is. Thank you in advance professor! Ps: everything should be coded in C AND NOT C++
Consider a square region in the first quadrant of the Cartesian plane whose bottom left and upper
right corners have coordinates (0,0) and (100,100), respectively. A text file contains a sequence of
rectangles, one per line, with sides parallel to the Cartesian axes. Each rectangle is identified by
the x and y coordinates of the bottom left and upper right corners, reported with spaces as
separators. The coordinates are integers between 0 and 100, with extremes included. Write a
function:
int arealntersection(FILE * fp);
that receives as a parameter a pointer to the file (already open) and returns the total area of the
intersecting regions (that is, the area of the regions that are covered by at least two rectangles)
Example of execution: (for the sake of simplicity, we report a smaller region with x and y
coordinates in the interval 0..10)
y
6.
0 1 2 3 4 5 6 7 8 9 10
If the file of the example contains 1 24 4 on the first line (see light-grey rectangle) and 3 358 in
the second line (see dark-grey rectangle), the total area returned by the function should be 1.
OT 6 8
9
0 1 2 3 4 5
Transcribed Image Text:Consider a square region in the first quadrant of the Cartesian plane whose bottom left and upper right corners have coordinates (0,0) and (100,100), respectively. A text file contains a sequence of rectangles, one per line, with sides parallel to the Cartesian axes. Each rectangle is identified by the x and y coordinates of the bottom left and upper right corners, reported with spaces as separators. The coordinates are integers between 0 and 100, with extremes included. Write a function: int arealntersection(FILE * fp); that receives as a parameter a pointer to the file (already open) and returns the total area of the intersecting regions (that is, the area of the regions that are covered by at least two rectangles) Example of execution: (for the sake of simplicity, we report a smaller region with x and y coordinates in the interval 0..10) y 6. 0 1 2 3 4 5 6 7 8 9 10 If the file of the example contains 1 24 4 on the first line (see light-grey rectangle) and 3 358 in the second line (see dark-grey rectangle), the total area returned by the function should be 1. OT 6 8 9 0 1 2 3 4 5
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Structure chart
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education