Lan Xiang's Square 1099 (简单几何 较坑 )
2015-09-13 11:12
323 查看
Lan Xiang's Square
时间限制:1000 ms | 内存限制:65535 KB难度:0描述Excavator technology which is strong, fast to Shandong to find Lan Xiang.Then the question comes.. :)for this problem , i will give you four points. you just judge if they can form a square.if they can, print "Yes", else print "No".Easy ? just AC it.输入T <= 105 cases.for every casefour points, and every point is a grid point .-10^8 <= all interger <= 10^8。grid point is both x and y are interger.输出Yes or No样例输入1 1 1 -1 1 -1 -1 1 -1样例输出
Yes
#include<stdio.h>#include<algorithm>#include<math.h>#include<string.h>using namespace std;struct zz{int x,y;}p[10];int cmp(zz x,zz y){if(x.x==y.x)return x.y>y.y;return x.x<y.x;}double len(int x1,int y1,int x2,int y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}int main(){int t;int i,j;scanf("%d",&t);while(t--){for(i=0;i<4;i++)scanf("%d%d",&p[i].x,&p[i].y);int a,b,c,d;sort(p,p+4,cmp);a=len(p[0].x,p[0].y,p[3].x,p[3].y);//排序后是0 3对角,1 2对角b=len(p[2].x,p[2].y,p[1].x,p[1].y);c=len(p[0].x,p[0].y,p[1].x,p[1].y);//c d 为相邻两边d=len(p[1].x,p[1].y,p[3].x,p[3].y);if(a!=b||a==0){printf("No\n");continue;}else if(a==b){if(c==d)printf("Yes\n");elseprintf("No\n");}}return 0;}
相关文章推荐
- C++-----利用括号递归实现的加减乘除
- Activity
- 任意长度的高精度大整数加法
- 数据结构之数组实现哈希表应用总结篇
- STL学习之set
- 【转载】架构师速成-如何高效编程
- 【转载】一次面试引发的思考(中小型网站优化思考)
- JS-数组操作
- Spring面试问答
- Matlab——subplot函数
- phonegap学习日志01
- MySQL的半同步复制
- 小猫统计——根据Excel文件或者文本文件自动建表
- Swift 全功能的绘图板开发
- asp.net-mvc的传值方式
- 中兴软件开发面试
- 仿微信/支付宝的密码输入框效果 android
- 百度地图api 实现 地址选择框
- Single Number II
- 【网络】(五)避免僵尸进程