DIGIT-ARC read-only archive · snapshot: July 23, 2026

Another C/C++ Problem

8 posts · originally from https://geek.digit.in/community/threads/another-c-c-problem.71558/

iNFiNiTE
iNFiNiTE Original post #1
Oct 25, 2007 at 9:37 PM
Hi Guys,

Here is one problem which one of my friends sent it to me. Maybe some of u can work it out..


Given a text file where each line is one of the following formats:
node x y
neighbour x y
There will be one node line and n neighbour lines (where n is an
arbitrary number). Your job is to compute the region of space that is
nearer to the node than to any of the neighbours. The output is a text
file of the following format:
point x1 y1
point x2 y2
...
area <area>
The first k lines (k depends on the input) are the points on the
boundaries of the region of space. The final line gives me the total
area of the region. Note that area can be infinite if the region is
unbounded. If so, just print "Infinite" for area.


Here r the Sample Inputs:
sample ip 1
node 0.0 0.0
neighbour 0.0 1.0
neighbour 1.0 0.0
neighbour -1.0 0.0
neighbour 0.0 -1.0

sample ip2
node 0.0 0.0
neighbour 0.0 1.0
neighbour -1.0 0.0
neighbour 0.0 -1.0

And the Sample Outputs:
sample op1
point 0.5 0.5
point 0.5 -0.5
point -0.5 -0.5
point -0.5 0.5
area 1.0

sample op2
point 0.5 0.5
point 0.5 -0.5
area infinite
Gigacore
Oct 25, 2007 at 9:52 PM
you could've posted this in dedicated C program thread in this section which is a sticky thread
QwertyManiac
Oct 25, 2007 at 10:08 PM
^^
This is what I was afraid of, why all things going into a sticky? Still, it appears valid you say that but hey, we got an entire section didn't we? More descriptive titles please!
Gigacore
Oct 25, 2007 at 10:19 PM
hmm but what i think is that, if all the members use a single thread, it will be easy to access information by others who are in search of solution. :)
please cope qwerty :)
S
Oct 26, 2007 at 7:35 AM
^^^ True, but if we have multiple queries on the same page, matching queries with answers will itself be a slight headache...

Arun
Gigacore
Oct 26, 2007 at 8:45 AM
well, let members use that to post just their programs and help others. . . and even if other member finds any mistake in the program they can suggest good techniques :)
fun2sh
fun2sh #7
Oct 26, 2007 at 10:05 PM
could u be more specific to ur question. i didnt understood it
iNFiNiTE
Oct 27, 2007 at 7:36 PM
^^ well actually i got the quesn in the same form. My frnd wasn too specific either. Will have to ask him to clarify.