UVA 11800 Determine the Shape
来源:互联网 发布:aop切面编程 android 编辑:程序博客网 时间:2024/06/04 19:55
题目链接:https://vjudge.net/problem/UVA-11800
题意:给n个四边形,判断是正方形,矩形,菱形,平行四边形,梯形还是普通四边形
水题,随便写,只要知道各个形状的规律就可以了
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#include<stack>#include<queue>#include<deque>#include<set>#include<map>#include<cmath>#include<vector>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair<int, int> PII;#define pi acos(-1.0)#define eps 1e-10#define pf printf#define sf scanf#define lson rt<<1,l,m#define rson rt<<1|1,m+1,r#define e tree[rt]#define _s second#define _f first#define all(x) (x).begin,(x).end#define mem(i,a) memset(i,a,sizeof i)#define for0(i,a) for(int (i)=0;(i)<(a);(i)++)#define for1(i,a) for(int (i)=1;(i)<=(a);(i)++)#define mi ((l+r)>>1)#define sqr(x) ((x)*(x))struct Point{ int x,y; Point(){} Point(int x,int y):x(x),y(y){} Point operator -(const Point& b) { return Point(x-b.x,y-b.y); }}a[5],p;bool cmp(const Point& a,const Point& b){ if(a.x!=b.x) return a.x<b.x; return a.y<b.y;}int cal(Point a,Point b)//判断两个向量是否垂直{ return a.x*b.x+a.y*b.y;}double len(Point a,Point b)//计算长度是否相等{ return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));}bool px(Point a,Point b,Point c,Point d)//叉乘计算是否平行{ return (a.x-b.x)*(c.y-d.y)==(a.y-b.y)*(c.x-d.x);}const int inf=0x3f3f3f3f;int t;int main(){ sf("%d",&t); for1(i,t) { for1(i,4) sf("%d%d",&a[i].x,&a[i].y); sort(a+1,a+5,cmp);//将四个点按照横坐标小的在前面,相同的话纵坐标小的在前面的 double p=len(a[1],a[2]); double b=len(a[1],a[3]); int c=cal(a[1]-a[2],a[1]-a[3]); int f=cal(a[1]-a[4],a[2]-a[3]); bool d=px(a[1],a[2],a[3],a[4]); bool es=px(a[1],a[3],a[2],a[4]); bool q=px(a[1],a[4],a[2],a[3]); pf("Case %d: ",i); if(p==b&&!c&&d&&es)puts("Square"); else if(!c&&d&&es)puts("Rectangle"); else if(d&&es&&!f)puts("Rhombus"); else if(d&&es)puts("Parallelogram"); else if(d||es||q)puts("Trapezium"); else puts("Ordinary Quadrilateral"); } return 0;}
阅读全文
0 0
- UVa 11800 - Determine the Shape
- uva 11800 - Determine the Shape
- UVA 11800 Determine the Shape
- UVa 11800 Determine the Shape
- UVA 11800 - Determine the Shape
- uva 11800 - Determine the Shape
- UVA 11800 Determine the Shape
- UVa 11800 - Determine the Shape
- UVA 11800 Determine the Shape
- UVA 11800 - Determine the Shape 几何
- UVa 11800 Determine the Shape(几何)
- [UVA]11800-Determine the Shape(计算几何)
- UVA 11800 - Determine the Shape(计算几何)
- 几何 入门题 UVA 11800 - Determine the Shape
- UVA 11800 —— Determine the Shape(几何基础)
- UVA 11800 Determine the Shape(判四边形)
- Determine the Shape - UVa 11800 凸包判断四边形
- uva 11800 Determine the Shape 判断四边形形状(计算几何)
- vs2015执行vs2013程序缺少dll的问题
- Modeling and Analyzing the Influence of Chunk Size Variation on Bitrate Adaptation in DASH 名字解释0728
- |2055|来淄博旅游
- new day
- 机器学习-->集成学习-->决策树详解
- UVA 11800 Determine the Shape
- php中property_exists方法的理解
- SONY·ILCE-6300L/BCN2·购买清单
- TASKCTL4.1集群与负载均衡部署过程
- hbase性能调试
- Bootstrap源码之旅-CSS环境搭建
- SwipeRefreshLayout与webview冲突解决方案
- 2017 Multi-University Training Contest
- 断点续传分析及实现