首页 技术 正文
技术 2022年11月6日
0 收藏 837 点赞 356 浏览 898 个字

三角形面积

时间限制:3000 ms  |  内存限制:65535 KB难度:2 

描述
给你三个点,表示一个三角形的三个顶点,现你的任务是求出该三角形的面积

 

输入
每行是一组测试数据,有6个整数x1,y1,x2,y2,x3,y3分别表示三个点的横纵坐标。(坐标值都在0到10000之间)
输入0 0 0 0 0 0表示输入结束
测试数据不超过10000组
输出
输出这三个点所代表的三角形的面积,结果精确到小数点后1位(即使是整数也要输出一位小数位)
样例输入
0 0 1 1 1 3
0 1 1 0 0 0
0 0 0 0 0 0
样例输出
1.0
0.5
 #include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
double get_side(int x1,int y1,int x2,int y2)
{
double side=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
return side;
} int main()
{
double s,a,b,c;int x1,x2,x3,y1,y2,y3;
while(cin>>x1>>y1>>x2>>y2>>x3>>y3,x1||x2||x3||y1||y2||y3)
{
a=get_side(x1,y1,x2,y2);
b=get_side(x1,y1,x3,y3);
c=get_side(x2,y2,x3,y3);
double p=(a+b+c)/;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<setprecision()<<s<<endl; }
return ;
}
 #include<stdio.h>
#include<math.h>
int main()
{
int a,b,c,d,e,r,s;
while()
{
scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&r);
if(a==&&b==&&c==&&d==&&e==&&r==) return ;
s=(a*d+b*e+c*r)-(a*r+d*e+b*c);
if(s<) s=-s;
printf("%.1f\n",s/2.0); }return ;
}

上一篇: HTML+CSS+JS简介
下一篇: android- 菜单
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,087
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,562
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,412
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,185
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,821
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905