题目链接

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. 【vim环境配置】解决ubuntu上 由YouCompleteMe插件配置不当引起的 自动补全失效的问题

    背景: 由于不可抗拒的原因,学习环境由之前centos的一台机器上,变成了ubuntu的一台机器上.因此,需要在新的ubuntu的机器上再配置一次vim环境.算起来这已经是第三次配置vim环境了(ma ...

  2. Eclipse AmaterasUML 安装及使用

    AmaterasUML 对于我来说,是一个非常好用的UML插件. 用它来将我写过的一些Android程序进行逆工程非常好用,只不过,不能体现出包,这是一个小小的遗憾. 这个是它的主页地址:http:/ ...

  3. C#调用C++编写的dll

    界面还是C#写的方便点,主要是有一个可视化的编辑器,不想画太多的时间在界面上.但是自己又对C++了解的多一些,所以在需要一个良好的界面的情况下,使用C++来写代码逻辑,将其编译成一个dll,然后用C# ...

  4. 常用模块(chardet)

    作用:检测二进制的编码格式,不是百分百正确 import chardet f = open('test.txt', 'rb')data = f.read()print(data)result = ch ...

  5. m个苹果放在n个盘子中有多少种结果

    题目 m个苹果放在n个盘子中有多少种结果,前置条件: 允许存在空盘 重复的摆放结果忽略不计 根据题意,也就是有3种情况,的确完全重复的摆放方式是没多大意义的 思路 这题可以用枚举的描述方式进行尾递归求 ...

  6. 剑指offer-合并两个排序链表16

    题目描述 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. class Solution: # 返回合并后列表 def Merge(self, pHead1 ...

  7. Python模块学习:logging 日志记录

    原文出处: DarkBull    许多应用程序中都会有日志模块,用于记录系统在运行过程中的一些关键信息,以便于对系统的运行状况进行跟踪.在.NET平台中,有非常著名的第三方开源日志组件log4net ...

  8. lintcode-92-背包问题

    92-背包问题 在n个物品中挑选若干物品装入背包,最多能装多满?假设背包的大小为m,每个物品的大小为A[i] 注意事项 你不可以将物品进行切割. 样例 如果有4个物品[2, 3, 5, 7] 如果背包 ...

  9. vue2.0中vue-router使用总结

    #在vue-cli所创建的项目中使用 进入到项目的目录后使用  npm install vue-router --save  安装vue-router,同时保存在webpack.Json配置文件中,然 ...

  10. jQuery - AJAX get()和post()方法

    jQuery get()和post()方法用于通过HTTP GET或POST请求从服务器请求数据. HTTP请求:GET VS POST 两种在客户端和服务器端进行请求-响应的常用方法是:GET和PO ...