poj2365---求多边形边长总和
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define pi acos(-1) struct point{
double x,y;
}first,last,now;
double dist(struct point *a,struct point *b)
{
return sqrt((a->x - b->x)*(a->x - b->x)+(a->y - b->y)*(a->y - b->y));
} int main()
{
int n,i;
double ans=0.0,r;
scanf("%d %lf",&n,&r);
ans+=*pi*r;
scanf("%lf %lf",&first.x,&first.y);
last=first;
for(i=;i<n;i++)
{
scanf("%lf %lf",&now.x,&now.y);
ans+=dist(&last,&now);
last=now;
}
ans+=dist(&first,&last);
printf("%.2f\n",ans);
return ;
}
用结构存储一个点的x,y坐标
结构指针(p)做参数,p->成员名
(*p).成员
在结构指针做参数的函数头部这样写:
double a(struct point *p1,struct point *p2)
struct point 相当于类型(int)
poj2365---求多边形边长总和的更多相关文章
- UVALive 4426 Blast the Enemy! --求多边形重心
题意:求一个不规则简单多边形的重心. 解法:多边形的重心就是所有三角形的重心对面积的加权平均数. 关于求多边形重心的文章: 求多边形重心 用叉积搞一搞就行了. 代码: #include <ios ...
- poj 1474 Video Surveillance - 求多边形有没有核
/* poj 1474 Video Surveillance - 求多边形有没有核 */ #include <stdio.h> #include<math.h> const d ...
- 三角剖分求多边形面积的交 HDU3060
//三角剖分求多边形面积的交 HDU3060 #include <iostream> #include <cstdio> #include <cstring> #i ...
- Lifting the Stone(求多边形的重心—)
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- hdu 2036 求多边形面积 (凸、凹多边形)
<题目链接> Problem Description “ 改革春风吹满地,不会AC没关系;实在不行回老家,还有一亩三分地.谢谢!(乐队奏乐)” 话说部分学生心态极好,每天就知道游戏,这次考 ...
- poj 3130 How I Mathematician Wonder What You Are! - 求多边形有没有核 - 模版
/* poj 3130 How I Mathematician Wonder What You Are! - 求多边形有没有核 */ #include <stdio.h> #include ...
- hdu 2528:Area(计算几何,求线段与直线交点 + 求多边形面积)
Area Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- hdu 1115:Lifting the Stone(计算几何,求多边形重心。 过年好!)
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- poj 1654:Area 区域 ---- 叉积(求多边形面积)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19398 Accepted: 5311 利用叉积求多边形面 ...
随机推荐
- Android 旋转字体 实现(应用角标,如:新,火等关键字)
在安卓应用中常见应用图标,或者gridview ,listview每个条目上有新,火,等45度旋转的字体,然后一个红色背景,引起用户关注,来一下实现方式: 自定义一个textview,绘制字体的时候, ...
- JavaScript处理HTML DOM
本来只想好好写一篇博文,最后弄到好像重构一样了,越做越不满意,先这样吧:) HTML DOM - JavaScript处理HTML DOM 获取HTML元素 改变HTML元素 增删HTML元素 添加事 ...
- 查询无序列表中第K小元素
当需要在无需列表中寻找第k小的元素时,一个显然的方法是将所有数据进行排序,然后检索k个元素.这种方法的运行时间为O(n log(n)). 无序列表调用分区函数将自身分解成两个子表,其长度为i和n-i. ...
- 此证书的签发者无效Missing iOS Distribution signing identity问题解决
问题描述 今天准备打包上传AppStore,结果Xcode报以下错误:Missing iOS Distribution signing identity for XXXXXX 查看证书后发现,Deve ...
- ftk学习记(icon篇)
[声明:版权全部,欢迎转载.请勿用于商业用途. 联系信箱:feixiaoxing @163.com] 在開始今天的文章之前.我们还是先看一下上一节的效果图. 大家能够參照上一节的解说,是不是存在这种 ...
- OAuth 2.0 for MVC, Two Legged Implementation
OAuth 2.0 for MVC, Two Legged Implementation tdupont Fri, Mar 18 2011 9:30 AM 13 OAuth 1.0 was one ...
- Java开发常用下载的网址
cygwin国内镜像:http://mirrors.sohu.com/cygwin/ 旧版本的ant下载:http://archive.apache.org/dist/ant/ 旧版本的nutch下载 ...
- CentOS7与Win7双系统引导问题
先安装的Win7,后安装的CentOS7,结果系统引导就只有CentOS7了.记得以前CentOS6.x系列没这个问题,主要是由于CentOS7.x使用grub2的原因吧. 方案一:使用Win PE. ...
- SQL Server表和字段说明的增加和更新
1. 增加字段说明 EXEC sp_addextendedproperty 'MS_Description', 'some description', 'user', ...
- CSS3中新增的内容
(整理中······) 一.选择器 新增的伪类 1.p:first-of-type 选择属于其父元素的首个 <p> 元素的每个 <p> 元素. 2.p:last-of-ty ...