
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Coordinates of rectangle with given points lie inside in C++
In this tutorial, we will be discussing a program to find the coordinates of rectangle
with given points lying inside.
For this we will be provided with some coordinate points. Our task is to find the smallest rectangle such that all the points lie inside it and it should have its sides parallel to the coordinate axis.
Example
#include <bits/stdc++.h> using namespace std; //calculating the coordinates of smallest rectangle void print_rectangle(int X[], int Y[], int n){ //finding minimum and maximum points int Xmax = *max_element(X, X + n); int Xmin = *min_element(X, X + n); int Ymax = *max_element(Y, Y + n); int Ymin = *min_element(Y, Y + n); cout << "{" << Xmin << ", " << Ymin << "}" << endl; cout << "{" << Xmin << ", " << Ymax << "}" << endl; cout << "{" << Xmax << ", " << Ymax << "}" << endl; cout << "{" << Xmax << ", " << Ymin << "}" << endl; } int main(){ int X[] = { 4, 3, 6, 1, -1, 12 }; int Y[] = { 4, 1, 10, 3, 7, -1 }; int n = sizeof(X) / sizeof(X[0]); print_rectangle(X, Y, n); return 0; }
Output
{-1, -1} {-1, 10} {12, 10} {12, -1}
- Related Questions & Answers
- Find minimum area of rectangle with given set of coordinates in C++
- Queries on count of points lie inside a circle in C++
- C program to find in which quadrant the coordinates lie.
- Count the number of rhombi possible inside a rectangle of given size in C++
- Generate a Pseudo-Vandermonde matrix of given degree with float array of points coordinates in Python
- Generate a Pseudo-Vandermonde matrix of given degree with complex array of points coordinates in Python
- Find Corners of Rectangle using mid points in C++
- Maximum area of rectangle possible with given perimeter in C++
- C++ Program to Check if a Given Set of Three Points Lie on a Single Line or Not
- Possible number of Rectangle and Squares with the given set of elements in C++
- Count BST subtrees that lie in given range in C++
- Generate pseudo Vandermonde matrix of Chebyshev polynomial with float array of points coordinates in Python
- Find coordinates of the triangle given midpoint of each side in C++
- Program to count number of points that lie on a line in Python
- Count BST nodes that lie in a given range in C++
Advertisements