第1个回答 2014-03-02
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TTest
{
class Sjx
{
double a;
double b;
double c;
double area;
public Sjx(double a, double b, double c)
{
this.a = a;
this.b = b;
this.c = c;
}
private double getArea()
{
double p = (a + b + c) / 2;
double s;
s = Math.Sqrt(p*(p-a)*(p-b)*(p-c));
return s;
}
static void Main(string[] args)
{
Console.WriteLine("输入a");
double a=Convert.ToInt32( Console.ReadLine());
Console.WriteLine("输入b");
double b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("输入c");
double c = Convert.ToInt32(Console.ReadLine());
Sjx sjx = new Sjx(a, b, c);
sjx.area = sjx.getArea();
Console.WriteLine("三角形的面积:"+sjx.area);
Console.ReadKey();
}
}
}本回答被网友采纳