UESTC 93 King's Sanctuary 基础
来源:互联网 发布:知乎js游戏引擎 编辑:程序博客网 时间:2024/04/28 23:34
题目大意
按顺时针方向给定四个点的坐标,要你判断它们所组成的四边形的形状。
解体思路
将四条边以向量的形式保存下来,根据不同形状的不同特点来判断。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <queue>#include <vector>#include <cmath>#include <set>#include <map>using namespace std;struct point{ int x,y;};int main(){ int t; scanf("%d",&t); for(int cas=1;cas<=t;cas++) { point p[5]; for(int i=0;i<4;i++) scanf("%d%d",&p[i].x,&p[i].y); //四条边的向量 int ax=(p[1].x-p[0].x); int ay=(p[1].y-p[0].y); int bx=(p[1].x-p[2].x); int by=(p[1].y-p[2].y); int cx=(p[3].x-p[2].x); int cy=(p[3].y-p[2].y); int dx=(p[3].x-p[0].x); int dy=(p[3].y-p[0].y); printf("Case #%d: ",cas); if(bx*dy==by*dx&&ax*cy==ay*cx)//对边平行 { if(ax*bx+ay*by==0)//邻边90度 { if(ax*ax+ay*ay==bx*bx+by*by)//邻边相等 printf("Square\n"); else printf("Rectangle\n"); } else if(ax*ax+ay*ay==bx*bx+by*by)//邻边相等 { printf("Diamond\n"); } else { printf("Parallelogram\n"); } } else { printf("Others\n"); } } return 0;}
0 0
- UESTC 93 King's Sanctuary 基础
- King's Sanctuary
- CDOJ King's Sanctuary 几何
- CDOJ 93 King's Sanctuary【判断四边形形状】
- sdau 省赛热身4 K - King's Sanctuary
- 弱校联萌十一大决战之背水一战K. King's Sanctuary
- UESTC 1014 The King and King boss 鸽巢原理
- King's Man
- 1904 King's Quest
- PKU1904 king's quest
- poj1904 - King's Quest
- hdu3861The King’s Problem
- hdu3861The King’s Problem
- King's Cake
- hdu5641 king's phone
- hdu----King's Phone
- hdu5642 King's Order
- King's Phone
- Kotlin开发Android笔记12:集合和函数操作符
- SDUT OJ 2413 n a^o7 !
- 关于RHEL 5 下scsi_id 无返回值的问题解决(2) 完全解析
- 一台电脑控制百台手机批量操作
- Xcode做ios开发时 message sent to deallocated instance问题的解决方法(gdb和lldb)
- UESTC 93 King's Sanctuary 基础
- Android 内存泄漏
- POJ 2236 Wireless Network
- 分布式服务弹性框架“Hystrix”实践与源码研究(一)
- POJ Channel Allocation 1129(dfs+四色定理)
- loadrunner:错误27796
- Android 使用zxing扫描二维码横屏转竖屏
- The operation couldn’t be completed. (LaunchServicesError error 0.)
- 在oracle中创建自动增长字段