Another C/C++ Problem

Status
Not open for further replies.

iNFiNiTE

The cake is a lie!!!
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
 
Last edited:

QwertyManiac

Commander in Chief
^^
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

Dreamweaver
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 :)
 

sakumar79

Technomancer
^^^ True, but if we have multiple queries on the same page, matching queries with answers will itself be a slight headache...

Arun
 

Gigacore

Dreamweaver
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 :)
 
OP
iNFiNiTE

iNFiNiTE

The cake is a lie!!!
^^ well actually i got the quesn in the same form. My frnd wasn too specific either. Will have to ask him to clarify.
 
Status
Not open for further replies.
Top Bottom