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_实现静默安装和卸载应用
转:http://www.cnblogs.com/ondream/archive/2012/04/13/2446138.html 前段时间做了一个批量安装卸载应用程序的小应用,由于安装卸载应用程序的部 ...
- phpcms 调用全站最新发布数据
phpcms模板标签没有调用全站最新发布的数据 所以参考phpcms本身自带的lists方法写了一个Countlists调用全站数据 /** * 全站最热 * @param $data */ publ ...
- SQL Server 加密层级
---------------------------------------------------------------------------------------------------- ...
- Silverlight中无法设置卫星程序集为中立资源程序集
熟悉.Net资源文件体系的人都知道,中立资源程序集(Neutral Resource Assembly)的作用在于,一旦指定语言文化(Culture)的资源查找不到,便会Fallback到中立资源程序 ...
- C语言的本质(1)——计算机与二进制
人类的计数方式通常是"逢十进一",称为十进制(Decimal),大概因为人有十个手指,所以十进制是最自然的计数方式,各民族的文字中都有十个数字,而阿拉伯数字0-9是目前最广泛采用的 ...
- getopt vs getopts
getopt示例 #!/bin/bash aflag=no args=`getopt a: $@` ]; then echo 'Usage: ...' exit fi set -- $args ] d ...
- 【Daily】 2014-4-28
KEEP GOING 表达产品想法, 探讨产品问题, 倾听可能性问题. 一次就做好, 有成果展示, 主动展示 先确立图, 后确立代码. Hold dream, and never let it go ...
- zoj2588 Burning Bridges(无向图的桥)
题目请戳这里 题目大意:给一张无向图,现在要去掉一些边,使图仍然连通,求不能去掉的边. 题目分析:就是求无向图的桥. tarjan算法跑一遍,和无向图割点十分类似,这里要找low[v] > df ...
- CodeSmith exclude global 文件和文件夹问题 与 输入中文显示乱码问题
1.打开C:/Documents and Settings/你的用户名/Application Data/CodeSmith/v4.1/CodeSmithGui.config文件. 2.在<te ...
- C# foreach获取集合元素索引的坑
,}; foreach(var prepareId in prepareIds) { Console.WriteLine(prepareIds.IndexOf(prepareId)); } 执行结果如 ...