Problem Description

There is a cycle with its center on the origin.

Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other

you may assume that the radius of the cycle will not exceed 1000.

Input

There are T test cases, in each case there are 2 decimal number representing the coordinate of the given point.

Output

For each testcase you are supposed to output the coordinates of both of the unknow points by 3 decimal places of precision 

Alway output the lower one first(with a smaller Y-coordinate value), if they have the same Y value output the one with a smaller X.

NOTE

when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.

Sample Input

2

1.500 2.000

563.585 1.251

Sample Output

0.982 -2.299 -2.482 0.299

-280.709 -488.704 -282.876 487.453

译:

问题描述:

有一个以原点为中心的圆

现在给你一个圆上的点,要求你找到圆上的另外的两个点,保证这三个点彼此之间的距离最大

你可以假设圆的半径不超过1000

输入:

有T个测试数据,每个测试数据要求输入两个十进制数代表给定点的坐标

输出

对于每个测试用例,您应该输出两个未知点的坐标,精确到小数点后3位

总是先输出较低的值(Y坐标值较小),如果它们的Y值与较小X值的值相同的话。

请注意

当输出时,如果X1和X2的绝对值小于0.0005,我们假设它们相等。

样例输入

2

1.500 - 2.000

563.585 - 1.251

样例输出

0.982 -2.299 -2.482 0.299

-280.709 -488.704 -282.876 487.453

思路:圆内接正三角形时,3个点彼此之间距离最大,可以先求角度(利用atan2可以由斜率得到角度),每次旋转120,用极坐标的方式再求直角坐标。

#include<stdio.h>
#include<math.h>
#define PI 3.1415926
int main() {
double x, y, r, a;
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lf%lf", &x, &y);
r = sqrt(x*x + y * y); //求半径
a = atan2(y, x); //求角度
for (int i = 0; i < 2; i++) {
a -= PI * 2 / 3; //旋转120度
printf("%0.3lf %0.3lf", r * cos(a), r * sin(a));
if (i == 0)
printf(" ");
}
printf("\n");
}
return 0;
}

C语言编写程序计算圆上的点的坐标的更多相关文章

  1. 编写程序,计算当n=10000,20000,30000...100000时,π的值.求π的近似公式 π=4*(1-1/3+1/5-1/7+1/9-1/11+1/13-...+1/(2n-1)-1/(2n+1))

    该程序是求的 π 近似值,所以随着 i 的增大,值会无线接近于 3.1415926... 代码示例 : package judgment;/** * 编写程序,计算当n=10000,20000,300 ...

  2. Java初学者作业——编写程序计算实发工资(实践1)

    返回本章节 返回作业目录 需求说明: 腾讯为Java工程师提供了基本工资(8000元).物价津贴及房租津贴.其中物价津贴为基本工资的40%,房屋津贴为基本工资的25%.要求编写程序计算实发工资. 实现 ...

  3. 已知圆上三个点坐标,求圆半径 r 和 圆心坐标

    问题: 已知圆上三个点坐标分别为(x1,y1).(x2,y2).(x3,y3) 求圆半径R和圆心坐标(X,Y) X,Y,R为未知数,x1,y1,x2,y2,x3,y3为常数 则由圆公式:(x1-X)² ...

  4. JS Math.sin() 与 Math.cos() 用法 (含圆上每个点的坐标)

    Math.sin(x)      x 的正玄值.返回值在 -1.0 到 1.0 之间: Math.cos(x)    x 的余弦值.返回的是 -1.0 到 1.0 之间的数: 这两个函数中的X 都是指 ...

  5. C语言编写程序的大小端问题

    有时候,用C语言写程序需要知道大端模式还是小端模式,,由于寄存器大于一个字节(8bit),就会存在一个字节安排的问题,例如(16bit)的short型,(32bit)的int型,具体需要看具体的编译器 ...

  6. 【POJ 1981】Circle and Points(已知圆上两点求圆心坐标)

    [题目链接]:http://poj.org/problem?id=1981 [题意] 给你n个点(n<=300); 然后给你一个半径R: 让你在平面上找一个半径为R的圆; 这里R=1 使得这个圆 ...

  7. cp/tar/用c语言编写程序 实现cp命令的效果

    1.cp (拷贝) 已存在文件路径  要拷贝的文件路径 实现cp命令的代码如下: #include <stdio.h> //因为要在命令中得到两个路径,所以要用到main函数的两个参数 i ...

  8. python根据圆的参数方程求圆上任意一点的坐标

    from math import cos, sin,pi x0,y0=0,0 r=4.0 angle=-25 x1 = x0 + r * cos(angle * pi / 180) y1 = y0 + ...

  9. WPF在圆上画出刻度线

    思路 我们可以使用Ellipse先画出一个圆当背景,然后用Canvas再叠加画上刻度线,就能得到如下的效果 我们先用Ellipse画一个橙色的圆,然后将Canvas的宽度和高度绑定到Ellipse的宽 ...

随机推荐

  1. TestNG+Java+Selenium+Maven 代码实例

    搭环境时注意不要忘记testng的jar包,selenium的jar包 package com.guge.test; import org.testng.annotations.Test;import ...

  2. MySQL面试试题与答案

    本次试题设计两个表:student.exam student表 exam表 一.写一条SQL语句,按学号排序输出数学成绩 SELECT s.sno sno,score FROM exam e,stud ...

  3. Security注解:@PreAuthorize,@PostAuthorize, @Secured, EL实现方法安全

     说明 (1)JDK版本:1.8(2)Spring Boot 2.0.6(3)Spring Security 5.0.9(4)Spring Data JPA 2.0.11.RELEASE(5)hibe ...

  4. C 语言 保留的关键字

    auto,break,case,char,const,continue, default,do,double,else,enum,extern, float,for,goto,if,int,long, ...

  5. java面试总结(资料来源网络)

    core java: 一.集合 1.hashMap 结构如图: HashMap在Map.Entry静态内部类实现中存储key-value对. HashMap使用哈希算法.在put和get方法中.它使用 ...

  6. redis-python

    一:缓存数据库介绍 NoSQL(NoSQL = Not Only SQL ),意即“不仅仅是SQL”,泛指非关系型的数据库,随着互联网web2.0网站的兴起,传统的关系数据库在应付web2.0网站,特 ...

  7. React props

    class WebSite extends React.Component { constructor() { super(); this.state = { name: "菜鸟教程&quo ...

  8. 给centos 7添加硬盘空间

    前言 今天在安装ambari的时候,制作amberi本地yum源的时候出现了一个问题,虚拟机的磁盘空间不足了,后来发现是因为这个节点之前本来只打算作为数据节点使用的,后来所以后来只给它分配了20G的硬 ...

  9. 一个linux 驱动升级的小问题记录

    重复踩了两次坑,所以简单记录下. 内核 3.10. 在修改了驱动的gro实现之后,进行驱动版本的升级,make && make install 之后,发现tg3的驱动,没有生效. 相同 ...

  10. elasticsearch增删查改

    创建结构化索引 put http://127.0.0.1:9200/person{ "settings" : { "number_of_shards": 3, ...