PDA

View Full Version : Another C/C++ Problem


iNFiNiTE
25-10-2007, 09: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
25-10-2007, 09:52 PM
you could've posted this in dedicated C program thread in this section which is a sticky thread

QwertyManiac
25-10-2007, 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
25-10-2007, 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 :)

sakumar79
26-10-2007, 07: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
26-10-2007, 08: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
26-10-2007, 10:05 PM
could u be more specific to ur question. i didnt understood it

iNFiNiTE
27-10-2007, 07: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.