题目链接

Problem Description

Everyone know the story that how Newton discovered the Universal Gravitation. One day, Newton walked

leisurely, suddenly, an apple hit his head. Then Newton discovered the Universal Gravitation.From then

on,people have sovled many problems by the 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?

Input

The 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.

Output

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

Sample Input

2
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 Output

3.0 2.7
2.0 2.3

分析:

三角形的三个点的坐标,求出这个三角形的重心。

X=(x0+x1+x2)/3;

Y=(y0+y1+y2)/3;

代码:

#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
double x[3];
double y[3];
int n;
while(~scanf("%d",&n),n)
{
while(n--)
{
scanf("%lf%lf%lf%lf%lf%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2]);
printf("%.1lf %.1lf\n",(x[0]+x[1]+x[2])/3,(y[0]+y[1]+y[2])/3);
}
}
return 0;
}

HDU 2105 The Center of Gravity (数学)的更多相关文章

  1. HDU 2105 The Center of Gravity

    http://acm.hdu.edu.cn/showproblem.php?pid=2105 Problem Description Everyone know the story that how ...

  2. hdu 2105:The Center of Gravity(计算几何,求三角形重心)

    The Center of Gravity Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  3. hdu 2105

    #include <iostream> #include <stdio.h> using namespace std; int main() { double a,b,c,d, ...

  4. fzu 1330:Center of Gravity(计算几何,求扇形重心)

    Problem 1330 Center of Gravity Accept: 443    Submit: 830Time Limit: 1000 mSec    Memory Limit : 327 ...

  5. HDU 4342——History repeat itself——————【数学规律】

    History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. O ...

  6. hdu 1597 find the nth digit (数学)

    find the nth digit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  7. HDU 6659 Acesrc and Good Numbers (数学 思维)

    2019 杭电多校 8 1003 题目链接:HDU 6659 比赛链接:2019 Multi-University Training Contest 8 Problem Description Ace ...

  8. HDU 5019 Revenge of GCD(数学)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5019 Problem Description In mathematics, the greatest ...

  9. HDU 5476 Explore Track of Point 数学平几

    Explore Track of Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...

随机推荐

  1. html5学得好不好,看掌握多少标签

    html5学得好不好,看掌握多少标签 已回复 会员ID:wi701329 保密 62岁 时间:2016-06-28 06:52:49 html5你了解了多少?如果你还是入门阶段的话,或者还是一知半解的 ...

  2. c# 对List<T> 某字段排序,取TOP条数据

    //排序的对象里的字段数据准备 try { cmr.v4 = Double.Parse(cmr.v3) - Double.Parse(cmr.v2); } catch (Exception e) { ...

  3. 并查集——poj2492(带权并查集入门)

    一.题目回顾 题目链接:传送门 题意:给定n只虫子,不同性别的可以在一起,相同性别的不能在一起.给你m对虫子,判断中间有没有同性别在一起的. 二.解题思路 种类并查集 和poj1073的本质一样 详见 ...

  4. homework for Java

    public class Dog { private String name; private String color; private int age; public Dog(String nam ...

  5. windows服务那些事

    前一段时间由于项目需求,写了一个windows服务.下面总结如下: windows服务其实就是一些后台程序,和其他程序的主要区别是它运行于系统后台.微软公司为了方便我们自己定制我们的服务,提供了很多借 ...

  6. 算法(1)K-diff Pairs in an Array

    写在前面:研究操作系统,习惯了用C,但是在做算法题甚至构建大型系统时,C真的是噩梦.还是用C++比较好,基本算法很成熟,并可基于此实现更复杂的算法.那就边写算法边捡起来好久不用的C++吧! 题目:数组 ...

  7. Maven中mirrors和repository的关系

    一.前言 之前没有搞清楚pom.xml里面配置的repositorys节点配置的仓库和mirrors里面配置的仓库的“镜像”间的关系,特意去搜索了相关内容,这边有篇文章讲得透彻,所以这边转载一下~ 二 ...

  8. 通过 servletContext设置点击次数 利用的是全局变量的特性

  9. Brainf**k(一位数求max)

    题目大意:给你两个一位数,要你求出其中的较大值(使用$Brainf**k$) ($Brainf**k$简介,相当于有一个数组和一个指针,","为把数组当前位赋值为读入的数,&quo ...

  10. 从零开始实现Vue简单的Toast插件

    在前端项目中,有时会需要通知.提示一些信息给用户,尤其是在后台系统中,操作的正确与否,都需要给与用户一些信息. 1. 实例 在Vue组件的methods内,调用如下代码 `this``.$toast( ...