The center of gravity

Source: Internet
Author: User

Loading editor...

The center of gravity

Time Limit: 3000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 2423 accepted submission (s): 1324

Problem descriptioneveryone know the story that how Newton discovered the Universal Gravitation. One day, Newton received
Leisurely, suddenly, an apple hit his head. Then Newton discovered the Universal Gravitation. From then
On, people have sovled into problems by the theory of the Universal Gravitation. What's more, wo also
Have Known every object has its center of gravity.
Now, you have been given the coordinates of three points of a triangle. Can you calculate the center
Of gravity of the triangle?

Inputthe first line is an 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 are the coordinates of three points.
The input is terminated by n = 0.

Outputfor each case, print the coordinate, accurate up to 1 decimal places.

Sample input2
1.0 2.0 3.0 4.0 5.0 2.0
1.0 1.0 4.0 1.0 1.0 5.0
0

Sample output3.0 2.7
2.0 2.3

 1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4
5 int main( )
6 {
7 int N;
8 while(scanf("%d", &N), N) {
9 double x1,x2,y1, y2,x3,y3;
10 while (N--)
11 {
12 scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1, &x2, &y2,&x3,&y3);
13 printf("%.1lf %.1lf", (x1 + x2 + x3)/ 3, (y1 + y2 + y3)/3);
14 puts("");
15 }
16 }
17 return 0;
18 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.