freelanceprogrammers.org Forum Index » C

Questions


View user's profile Post To page top
pnadgir2004 Posted: Wed Jan 05, 2005 3:23 pm


Joined: 27 Dec 2004

Posts: 4
Questions
Hi,
 
I have a few questions and a few solutions which I would want someone to improvise
 
1. Finding the set of consecutive integers which sum up to the max
 
Suppose we have a list of integers .. say [1,3,0.-4,5,4,-6,0,8,-5] ... Now, in this list, the group (4,5) can be called the set of consecutive integers that sums up to the max total (i.e, 9). Now how do we write a program for this?
 
I was thinking on the lines of starting from 1 and summing up things. Then starting from 3 and summing up things... This does not seem to be efficient...
 
 
2. Suppose we have a square and a circle inside it (the circle touches all the four corners of the square and is inside it).. Now suppose we draw a circle which fits into one of the corners of the square (the small remaining space which is left at the four corners of the circle). What would be the radius of that smaller circle? I have attached a picture of this problem.
 
I am thinking of writing a c program to solve this puzzle ... anyone can come up with an answer without a program?
 
 
 

Yahoo! India Matrimony: Find your life partner
online.
Reply with quote
Send private message
View user's profile Post To page top
shashi_phatak Posted: Wed Jan 05, 2005 4:39 pm


Joined: 05 Jan 2005

Posts: 1
Questions
Hi,

On Wed, 5 Jan 2005, pnadgir nadgir wrote:

> 1. Finding the set of consecutive integers which sum up to the max
>
> Suppose we have a list of integers .. say [1,3,0.-4,5,4,-6,0,8,-5] ...
> Now, in this list, the group (4,5) can be called the set of consecutive
> integers that sums up to the max total (i.e, 9). Now how do we write a
> program for this?
>
> I was thinking on the lines of starting from 1 and summing up things.
> Then starting from 3 and summing up things... This does not seem to be
> efficient...
>
What I understand is, sum of two consecutive integers in a series has to
be maximum. Define sum of first two integers and call it max. Then have a
for loop for index i going from 2 to n-1 and add ith and (i+1)th integers.
If it is larger than max, set max to the addition. You will have the
maximum sum in max. Figure out how you will also get the two integers.

>
> 2. Suppose we have a square and a circle inside it (the circle touches
> all the four corners of the square and is inside it).. Now suppose we
> draw a circle which fits into one of the corners of the square (the
> small remaining space which is left at the four corners of the circle).
> What would be the radius of that smaller circle? I have attached a
> picture of this problem.
>

This is a geometry problem and not C problem. Let us say the length of
each side is 1 unit. Then the diameter of the circle is 1 and the distance
from a corner to the center of the circle is 1/sqrt(2). So the distance
between the left bottom corner and the point where red and blue circles
touch is 1/sqrt(2)-1/2 and the distance between top right corner and this
point is 1/sqrt(2)+1/2. Now, if you look at the diagram you will find that
radius of blue circle:1/sqrt(2)+1/2 = radius of red circle:1/sqrt(2)-1/2.
So the radius of red circle is (3-sqrt(2))/2 ( if my algebra is correct ).

Interesting problem.

Shashikant Phatak
Reply with quote
Send private message
View user's profile Post To page top
sailesh_pand... Posted: Wed Jan 05, 2005 8:17 pm


Joined: 05 Jan 2005

Posts: 1
Questions
 
Hi,
Here is a huge opportunity to help your friends/ ex-colleagues/ relatives/ acquaintances in building their career with infogain.
We are actively looking for software professionals at different levels with the detailed description about the position and skill set in the attachments.
 See the Attachment
Send Resume To : sailesh.panda@...  or
 
Sailesh.panda@...
 
 
 
Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard.
Reply with quote
Send private message
View user's profile Post To page top
ravinderreddy_o@... Posted: Thu Jan 06, 2005 12:51 am


Joined: 06 Jan 2005

Posts: 1
Questions
--- pnadgir nadgir <pnadgir2004@...> wrote:

> Hi,
>
> I have a few questions and a few solutions which I
> would want someone to improvise
>
> 1. Finding the set of consecutive integers which sum
> up to the max
>
> Suppose we have a list of integers .. say
> [1,3,0.-4,5,4,-6,0,8,-5] ... Now, in this list, the
> group (4,5) can be called the set of consecutive
> integers that sums up to the max total (i.e, 9). Now
> how do we write a program for this?

starting from first just add consecutive (+)ve no`s .
and save the sum in a temp variable .when (-)ve comes
leave it.and then sum another consecutive (+)no`s and
compare it with the previous one. max value will give
the set of integers.

> I was thinking on the lines of starting from 1 and
> summing up things. Then starting from 3 and summing
> up things... This does not seem to be efficient...
>
>
> 2. Suppose we have a square and a circle inside it
> (the circle touches all the four corners of the
> square and is inside it).. Now suppose we draw a
> circle which fits into one of the corners of the
> square (the small remaining space which is left at
> the four corners of the circle). What would be the
> radius of that smaller circle? I have attached a
> picture of this problem.
>
> I am thinking of writing a c program to solve this
> puzzle ... anyone can come up with an answer without
> a program?

Let length of side of the square = a.
then the diagnol length of square = a*sqrt(2)
diametre of big circle = a ( since it fits into
square)
let radius of small cirlcle =r
2 small circles will fit into either corner of the
square
4r+a=a*sqrt(2)
r=a(sqrt(2)-1)/4;
>
>
>
>
> Yahoo! India Matrimony: Find your life
partneronline.

> ATTACHMENT part 2 image/gif name=SquareCircle.gif



=====
work hard till u get what u want

regards,
Ravinder Reddy,
http://172.16.17.2/~ravinder



__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help