hdu2108

判断是否为凸边形

判断连续三点的叉乘

若为凸,内角<180;若为凹,内角>180

所以通过正负来判断

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N=100050;
struct node
{
int x,y;
}pnode[N]; int judge(int x,int y,int z)
{
return (pnode[y].x - pnode[x].x)*(pnode[z].y - pnode[y].y)-(pnode[z].x - pnode[y].x)*(pnode[y].y - pnode[x].y);
} int main()
{
int n; while(scanf("%d",&n) && n)
{
for(int i = 1;i <= n;i++)
scanf("%d%d",&pnode[i].x,&pnode[i].y);
pnode[n+1].x = pnode[1].x;
pnode[n+1].y = pnode[1].y;
pnode[n+2].x = pnode[2].x;
pnode[n+2].y = pnode[2].y;
int flag = 0;
for(int i = 1;i <= n;i++)
{
if(judge(i,i+1,i+2)<0)
{
flag = 1;
break;
}
}
if(flag )
printf("concave\n");
else
printf("convex\n"); }
return 0;
} hdu2036 求一个多边形的面积 分成许多个三角形来计算。 S△ = 向量AB 与 向量AC的叉乘/2 #include <stdio.h>
#include <math.h>
int main()
{
int n,i,j;
double S,x[101],y[101];
while(scanf("%d",&n) && n != 0)
{
for(i = 0;i < n;i++)
scanf("%lf%lf",&x[i],&y[i]);
x[i] = x[0];
y[i] = y[0];
S = 0;
for(j = 0;j < i;j++)
S += x[j] * y[j+1] - x[j+1] * y[j];
S = fabs(S / 2);
printf("%.1lf\n",S);
}
return 0;
}

  

HDU2108和HDU2036(叉乘)的更多相关文章

  1. [数据结构]——二叉树(Binary Tree)、二叉搜索树(Binary Search Tree)及其衍生算法

    二叉树(Binary Tree)是最简单的树形数据结构,然而却十分精妙.其衍生出各种算法,以致于占据了数据结构的半壁江山.STL中大名顶顶的关联容器--集合(set).映射(map)便是使用二叉树实现 ...

  2. AC日记——二叉堆练习3 codevs 3110

    3110 二叉堆练习3  时间限制: 3 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解       题目描述 Description 给定N(N≤500,000)和N个整 ...

  3. codevs 3110 二叉堆练习3

    3110 二叉堆练习3 http://codevs.cn/problem/3110/ 题目描述 Description 给定N(N≤500,000)和N个整数(较有序),将其排序后输出. 输入描述 I ...

  4. [LeetCode] Delete Node in a BST 删除二叉搜索树中的节点

    Given a root node reference of a BST and a key, delete the node with the given key in the BST. Retur ...

  5. [LeetCode] Serialize and Deserialize BST 二叉搜索树的序列化和去序列化

    Serialization is the process of converting a data structure or object into a sequence of bits so tha ...

  6. [LeetCode] Inorder Successor in BST 二叉搜索树中的中序后继节点

    Given a binary search tree and a node in it, find the in-order successor of that node in the BST. No ...

  7. [LeetCode] Verify Preorder Sequence in Binary Search Tree 验证二叉搜索树的先序序列

    Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary ...

  8. [LeetCode] Lowest Common Ancestor of a Binary Search Tree 二叉搜索树的最小共同父节点

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

  9. [LeetCode] Kth Smallest Element in a BST 二叉搜索树中的第K小的元素

    Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Not ...

随机推荐

  1. VMware安装时Error 1324. The path My Documents contains a invalid character的原因和解决方法

    终于找到了自己想要的答案,顶顶,吼吼~ 我今天安装VMware Workstation时,总是提示我Error 1324. The path My Documents contains a inval ...

  2. 02-移动端开发教程-CSS3新特性(中)

    1. 新的背景 背景在CSS3中也得到很大程度的增强,比如背景图片尺寸.背景裁切区域.背景定位参照点.多重背景等. 1.1 background-size设置背景图片的尺寸 cover会自动调整缩放比 ...

  3. 偶遇vue-awesome-swiper的坑

    最近用vue重构一个移动端的项目,碰到了不少坑,今天拿移动端最著名的轮播插件swiper为例来说,由于这个项目没用UI库,纯手写的样式,沿用老的插件,自然而然的选择了vue-awesome-swipe ...

  4. FTP传输文件被破坏的问题(Linux、Busybox)

    在网络设备上抓包后,通过FTP传输到本机,发现抓包文件破坏.更换tftp后文件正常,定位问题在FTP上. FTP的传输模式有两种:①ASCII  ②二进制 ①ASCII: 以ASCII编码的方式传输文 ...

  5. MySQL Group Relication 部署环境入门篇

      一:环境介绍   cenos 6.7 版本 数据库的版本5.7.19 二:部署规划单机多实例的部署   端口号 数据目录  group_repplicatoon 通信接口   3307 /data ...

  6. nginx配置反向代理详细教程(windows版)

    内容属于原创,如果需要转载,还请注明地址:http://www.cnblogs.com/j-star/p/8785334.html Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(I ...

  7. [洛谷P2234][HNOI2002] 营业额统计 - Treap

    Description Tiger最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况. Tiger拿出了公司的账本,账本上记录了公司成立以来每天的营业额. ...

  8. linux 安装jdk以及nginx详细过程

    一.安装jdk 1:首先下载jdk到本地,然后通过git 上传到linux服务器上 2:进入目录usr,并创建目录java,将jdk的压缩文件移动到该目录下 cd /usr mkdir java mv ...

  9. Docker Win 10 安装

    最近了解了一下Docker,不看不知道,一了解就完全被它给吸引住了.以往要装个环境,除了要准备一个Linux系统,然后在安装各种版本的类库,再安装我们需要各种应用服务(如Redis,Ngix,Mong ...

  10. 实现Winform端窗体关闭后刷新html网页内容

    一.首先要知道刷新网页的路径: frmPointEasyToBeat fpetBeat = new frmPointEasyToBeat(bookNoteId, userInfo.UserId); f ...