nyoj-1099-Lan Xiang's Square(几何,水题)

Posted 朤尧

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nyoj-1099-Lan Xiang's Square(几何,水题)相关的知识,希望对你有一定的参考价值。

题目链接

 1 /*
 2     Name:nyoj-1099-Lan Xiang‘s Square
 3     Copyright:
 4     Author:
 5     Date: 2018/4/26 9:19:19
 6     Description:
 7     给4个点,判断是否形成正方形 
 8     double类型的值比较大小,直接判断==0竟然A了,然而小于1e-6竟然WA
 9 */
10 #include <iostream>
11 #include <cstdio>
12 #include <algorithm>
13 using namespace std;
14 struct node {
15     double x, y;
16 }nodes[5];
17 double length_edge(node a, node b) {
18     return (b.x - a.x)*(b.x - a.x) + (b.y - a.y)*(b.y - a.y);
19 }
20 int main()
21 {
22 //    freopen("in.txt", "r", stdin);
23     int t;
24     cin>>t;
25     while (t--) {
26         for (int i=0; i<4; i++) 
27             cin>>nodes[i].x>>nodes[i].y;
28         double edge[4];
29         edge[0] = length_edge(nodes[0], nodes[1]);
30         edge[1] = length_edge(nodes[0], nodes[2]);
31         edge[2] = length_edge(nodes[0], nodes[3]);
32         if (count(edge, edge+3, 0) >0) {
33             cout<<"No"<<endl;
34             continue;
35         }
36         sort(edge, edge+3);
37 //        if (edge[0] - edge[2] + edge[1] < 1e-6 && (edge[0] - edge[1]) < 1e-6) { //WA        
38         if (edge[0] - edge[2] + edge[1] ==0  && (edge[0] - edge[1])  == 0) {         
39             cout<<"Yes"<<endl;
40         } else {
41             cout<<"No"<<endl;
42         }
43     }
44     return 0;
45 }

 

以上是关于nyoj-1099-Lan Xiang's Square(几何,水题)的主要内容,如果未能解决你的问题,请参考以下文章

东森娱乐直属_最高直属xiang?

hdu 4121 Xiangqi

MyEclipse安装插件

thymeleaf的使用

Android Studio编译错误:java.lang.UnsatisfiedLinkError,大神来看看啊

js实例4下拉菜单