Hdoj Title Address: Portal
The Center of GravityTime limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total Submission (s): 5570 Accepted Submission (s): 3179
Problem Descriptioneveryone know the story of how Newton discovered the Universal gravitation. One day, Newton walked
Leisurely, suddenly, an Apple hits his head. Then Newton discovered the Universal Gravitation.from then
On,people has sovled many problems by the the theory of the Universal gravitation. What's more, Wo Also
There are known every object with its Center of Gravity.
Now,you has been given the coordinates of three points of a triangle. Can you calculate the center
of gravity of the triangle?
Inputthe first line is a integer N,which is the number of test cases.
then n lines follow. Each line has 6 numbers X1,y1,x2,y2,x3,y3,which is the coordinates of three points.
The input is terminated by n = 0.
Outputfor, print the coordinate, accurate up to 1 decimal places.
Sample Input
21.0 2.0 3.0 4.0 5.0 2.01.0 1.0 4.0 1.0 1.0 5.00
Sample Output
3.0 2.72.0 2.3
#include <iostream> #include <stdio.h>using namespace Std;int main () { int n; while (scanf ("%d", &n) &&n) { double x1,x2,x3,y1,y2,y3; while (n--) { cin>>x1>>y1>>x2>>y2>>x3>>y3; printf ("%.1lf%.1lf\n", (X1+X2+X3)/3, (Y1+Y2+Y3)/3);}}}
acm--Triangle Center of Gravity--hdoj 2105--the center of gravity--Water