1132 -- 三角形面积
2015-08-31 16:50
330 查看
三角形面积
Time Limit:2000MS Memory Limit:65536K
Total Submit:968 Accepted:254
Description
给出三角形的三个边长为a,b,c,根据海伦公式来计算三角形的面积:
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
Input
输入数据只有一组,即为三角形的三个边长a,b,c(100>a,b,c>0且均为整数)。
Output
输出三角形的面积,两位小数。如果不是一个三角形,则输出错误提示信息:"Input error!"。
注意输出没有引号。
Sample Input
Sample Output
Source
Time Limit:2000MS Memory Limit:65536K
Total Submit:968 Accepted:254
Description
给出三角形的三个边长为a,b,c,根据海伦公式来计算三角形的面积:
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
Input
输入数据只有一组,即为三角形的三个边长a,b,c(100>a,b,c>0且均为整数)。
Output
输出三角形的面积,两位小数。如果不是一个三角形,则输出错误提示信息:"Input error!"。
注意输出没有引号。
Sample Input
3 4 5
Sample Output
6.00
Source
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AK1132 { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(); double[] a = new double[3]; for (int i = 0; i < 3; i++) a[i] = double.Parse(s[i]); Array.Sort(a); if (a[2] - a[0] >= a[1]) Console.WriteLine("Input error!"); else { double b = (a[0] + a[1] + a[2]) / 2; double c = Math.Sqrt(b * (b - a[0]) * (b - a[1]) * (b - a[2])); Console.WriteLine(c.ToString("0.00")); } //Console.ReadLine(); } } }
相关文章推荐
- 1131 -- 数列求和
- 二叉排序树
- Hadoop第4周练习—HDFS读写文件操作
- bzoj-2085 Hamsters
- 【Python爬虫学习笔记(3)】Beautiful Soup库相关知识点总结
- 关于在函数中返回动态的内存
- 数据结构与算法分析Java版练习1.15
- 关于ImageLoader 设置圆角参数后不显示图片的问题
- 《深入理解计算机系统》读书笔记3---关于程序运行的思考
- Hadoop 学习笔记
- 1130 -- 矩阵找值
- 剑指offer刷题之c实现的二叉搜索树转换成双向链表
- Unity3D学习笔记《Roll-a-Ball》一
- Hadoop第3周练习--Hadoop2.X编译安装和实验
- 删除字符串中的空格字符
- mac下安装redis
- HTML5 Canvas 绘图――使用 Canvas 绘制图形图文教程 使用html5 canvas 绘制精美的图
- Android与js交互实例
- 在c++中,vector是一个十分有用的容器,下面对这个容器做一下总结。
- 1129 -- 找用户名