Not Necessary but for some case only

On Tue, May 1, 2012 at 8:44 PM, Bhupendra Dubey <bhupendra....@gmail.com>wrote:

> Find the centroid
>
> X= (x1 +x2....xn)/N
> Y=(y1+y2......yn)/N
> This will precisely be the point no need to calculate and check with
> distance.
>
>
> On Tue, May 1, 2012 at 1:18 PM, mohit mishra <mohit7mis...@gmail.com>wrote:
>
>> Let me know if there is any bug
>> /*using centroid of plane */
>>
>> struct point
>> {
>> int x;
>> int y;
>> };
>> typedef struct point Point;
>> int main()
>> {
>> int n,i;
>> int d,dis;
>> float sum_x=0,sum_y=0;
>> Point centroid,final;
>> //clrcsr();
>> printf("how many points?  ");
>> scanf("%d",&n);
>> Point p[100];
>> printf("enter X and Y cordinates of %d points\n",n);
>> for(i=0;i<n;i++)
>> scanf("%d%d",&p[i].x,&p[i].y);
>> for(i=0;i<n;i++)
>> {
>>                 sum_x=sum_x+p[i].x;
>>                 sum_y=sum_y+p[i].y;
>>                 }
>>                centroid.x=(int)sum_x/n;
>>                centroid.y=(int)sum_y/n;
>> for(i=0;i<n;i++)
>> {
>> dis=distance(centroid,p[i]);
>>                 if(dis<d)
>>                 {
>>                                              d=dis;
>>                                              final.x=p[i].x;
>>                                              final.y=p[i].y;
>>
>>                                              }
>>                 }
>>                 printf("\n The point is (%3d  ,%3d)",final.x,final.y);
>> getch();
>> return 0;
>> }
>> int distance(Point A,Point B)
>> {
>>     int x,y;
>>     x=(A.x-B.x)*(A.x-B.x);
>>     y=(A.y-B.y)*(A.y-B.y);
>>     return sqrt(x+y);
>>     }
>>
>>
>> On Mon, Apr 30, 2012 at 4:34 PM, kosgi santosh <santoshko...@gmail.com>wrote:
>>
>>> how can we find centriod of n points in a plane?
>>>
>>>
>>>
>>>
>>>
>>> Regards,
>>> Santosh K.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> bhupendra dubey
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Abhishek Kumar
B.Tech(IT) Graduate
Allahabad
Contact no-+919663082731

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to