码迷,mamicode.com
首页 > 其他好文 > 详细

POJ 1940

时间:2015-06-10 17:06:47      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:

#include <iostream>
#include <iomanip>
#define MAXN 1000
using namespace std;

struct node 
{
    double x;
    double y;
};


node _node[MAXN];

double fun(double a,double b);
int main()
{
    //freopen("acm.acm","r",stdin);
    int n;
    int i;
    double tem_x;
    double tem_y;
    double x;
    double y;
    int sum;
    while(cin>>n)
    {
        tem_x = 0;
        tem_y = 0;

        for(i = 0; i < n; ++ i)
        {
            cin>>_node[i].x;
            cin>>_node[i].y;
        }
        
        for(i = 0; i < n-1; ++ i)
        {
            if(i % 2 == 0)
            {
                tem_x -= _node[i].x;
                tem_y -= _node[i].y;
            }
            else
            {
                tem_x += _node[i].x;
                tem_y += _node[i].y;
            }
        }

        tem_x *= 2;
        tem_y *= 2;
        x = fun(_node[n-1].x*2,-tem_x);
        y = fun(_node[n-1].y*2,-tem_y);
        cout<<n<<" ";
        cout<<setiosflags(ios::fixed)<<setprecision(6)<<x<<" "<<y<<" ";
        x = _node[0].x*2 - x;
        y = _node[0].y*2 - y;
        for(i = 1; i < n; ++ i)
        {
            cout<<setiosflags(ios::fixed)<<setprecision(6)<<x<<" "<<y<<" ";
            x = _node[i].x*2 - x;
            y = _node[i].y*2 - y;
        }
        cout<<endl;
    }
}

double fun(double a,double b)
{
    return (a+b)/2.0;
}

 

POJ 1940

标签:

原文地址:http://www.cnblogs.com/gavinsp/p/4566583.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!