梯形
Time Limit:1000MS Memory Limit:65536K
Total Submit:554 Accepted:255
Description
给出等腰梯形的上底、下底和高,要求计算该梯形的面积与周长。
Input
输入数据只有一行,每行依次出现三个数U、D、H,分别表示等腰梯形的上底、下底和高。( 0 < U < D, 0 < H)
Output
输出两行,第一行输出梯形的面积,第二行输出梯形的周长。(面积和周长均保留2位小数)
Sample Input
2 8 4
Sample Output
20.00
20.00
Source
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AK1034 {
class Program {
static void Main(string[] args) {
string[] sb = Console.ReadLine().Split();
double x = double.Parse(sb[0]), y = double.Parse(sb[1]), z = double.Parse(sb[2]);
double area = (x + y) * z / 2;
double perimeter = x + y + Math.Sqrt(4 * z * z + (y - x) * (y - x));
Console.WriteLine(area.ToString("0.00"));
Console.WriteLine(perimeter.ToString("0.00"));
}
}
}