Array and Strings – Geometry – Problem #4

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: hard

Problem Statement

Read N (to be read) 2-D coordinate points in a 2-D array, where the ith row represents the ith point, and first and second columns represent x and y coordinates in real numbers, respectively. It also reads another value T ( a real number), which decides whether two points are close or not. If the Euclidean distance between two points are less than T, the points are declared as close. Compute the pairs of points (in any order) which are close. Print also the closest and furthest pair among them. For example: N=4 The list of points: (0,0), (1,0), (1,2), (2,1) T=1.5 The output from the program would be as follows: List of close pairs: ((0,0),(1,0)), ((1,0),(2,1)), ((1,2),(2,1)) Closest pair: ((0,0),(1,0)) Furthest pair: ((0,0),(2,1)) [or ((0,0),(1,2))] Provide output for the following input data set. (i) N=4 The list of points: (1,1), (5.87,5), (1,10.45),(10,1) T=10.0 (ii) N=8 The list of points: (-1,45.4), (5.8,5), (8,9.45), (-5.12,-67), (3,45.89), (-4,-4.6), (12,-50.12),(50,-50) T=12.0 N.B. Your program may be tested with other input data set.

Back to Lab Problems
Array and Strings/Geometry/Problem #4

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #4

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.