1132 -- 三角形面积
来源:互联网 发布:sql查询去除重复项 编辑:程序博客网 时间:2024/05/16 13:06
三角形面积
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(); } } }
0 0
- 1132 -- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- 三角形面积
- C++动态数组使用方法
- apache cgi机制核心实现代码
- 遵从CLS
- 26. 面向对象程序设计
- An Efficient Resource Allocation Scheme for Cross- Cloud Federation
- 1132 -- 三角形面积
- memcpy, strcpy, strlen, strcmp, itoa, atoi 的函数实现
- CheckBox选择框和文字设置间距
- Android 网络编程——Android 中的 HTTP 编程
- 计算机视觉与图像处理、模式识别、机器学习学科之间的关系
- HDU2813One fihgt one(KM匹配)
- poj 3070 Fibonacci
- DirectX3D游戏开发六 场景光照的实现
- 1133 -- 最近平方数