当前位置:网站首页>NOI OJ 1.3 17:计算三角形面积 C语言
NOI OJ 1.3 17:计算三角形面积 C语言
2022-06-23 10:12:00 【chd44】
描述
平面上有一个三角形,它的三个顶点坐标分别为(x1, y1), (x2, y2), (x3, y3),那么请问这个三角形的面积是多少。
输入
输入仅一行,包括6个单精度浮点数,分别对应x1, y1, x2, y2, x3, y3。
输出
输出也是一行,输出三角形的面积,精确到小数点后两位。
使用海伦公式计算得出三角形面积,先通过两点间距离公式求出三条边的长度,并计算出半周长。
#include<stdio.h>
#include<math.h>
int main(){
float a,b,c,d,e,f;
scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f);
float r1=sqrt((c-a)*(c-a)+(d-b)*(d-b));
float r2=sqrt((e-a)*(e-a)+(f-b)*(f-b));
float r3=sqrt((c-e)*(c-e)+(d-f)*(d-f));
float p=(r1+r2+r3)/2;
float s=sqrt(p*(p-r1)*(p-r2)*(p-r3));
printf("%.2f",s);
return 0;
}海伦公式:S=√p (p-a) (p-b) (p-c) p为半周长。
边栏推荐
- Mysql 的Innodb引擎和Myisam数据结构和区别
- 陆奇首次出手投资量子计算
- 我被提拔了,怎么和原来平级的同事相处?
- MySQL基础-笔记
- 2021-05-11instanceof和类型转换
- JVM简单入门-02
- Unity技术手册 - 形状(Shape)子模块 - Sprite、SpriteRenderer及生命周期内速度(Velocity over Lifetime)
- Liujinhai, architect of zhongang Mining: lithium battery opens up a Xintiandi for fluorine chemical industry
- 同花顺推荐么?手机开户安全么?
- 数值计算方法
猜你喜欢

文件IO(1)

2021-05-07 constructor

漫画 | Code Review快把我逼疯了!

File IO (1)

CVPR大会现场纪念孙剑博士,最佳学生论文授予同济阿里,李飞飞获黄煦涛纪念奖...

Mysql 的Innodb引擎和Myisam数据结构和区别

Cloud native database Amazon RDS

Bioinformatics | effective drug target correlation prediction based on interacting neural network

Unity技术手册 - 形状(Shape)子模块 - Sprite、SpriteRenderer及生命周期内速度(Velocity over Lifetime)

Three implementation methods of distributed lock
随机推荐
2021-05-10方法重写多态注意事项
Pet Feeder Based on stm32
What is JSX in the JS tutorial? Why do we need it?
Build a security video monitoring platform using Huawei cloud ECS server
数学分析_笔记_第2章:实数与复数
After the uncommitted transactions in the redo log buffer of MySQL InnoDB are persisted to the redo log, what happens if the transaction rollback occurs? How does the redo log handle this transaction
Lying trough, the most amazing paper artifact!
oracle中遇到的bug
漫画 | Code Review快把我逼疯了!
JVM简单入门-01
陆奇首次出手投资量子计算
SQL教程之 5 个必须知道的用于操作日期的 SQL 函数
Centre de calcul haute performance - nvme / nvme - of - nvme - of overview
2022高考季征文获奖名单公布
Unity技术手册 - 形状(Shape)子模块 - Sprite、SpriteRenderer及生命周期内速度(Velocity over Lifetime)
ICLR 2022 | dynamic convolution tadaconv in video and efficient convolution video understanding model tadaconvnext
Bi SQL drop & alter
同花顺是炒股的么?在线开户安全么?
Distributed common interview questions
Golang 快速上手 (3)