C#编程 已知三个点求组成三角形的周长和面积
2个回答
2013-09-25
2013-09-25
展开全部
程序: double x1 = Convert.ToDouble(this.textBox1.Text);
double y1 = Convert.ToDouble(this.textBox2.Text);
double x2 = Convert.ToDouble(this.textBox3.Text);
double y2 = Convert.ToDouble(this.textBox4.Text);
double x3 = Convert.ToDouble(this.textBox5.Text);
double y3 = Convert.ToDouble(this.textBox6.Text); double a = System.Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
double b = System.Math.Sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
double c = System.Math.Sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)); double L = a + b + c;
double p = L / 2;
double S = System.Math.Sqrt(p*(p - a)*(p - b)*(p - c)); MessageBox.Show("三角形周长:" + L.ToString() + Environment.NewLine + "三角形面积:" + S.ToString(), "提示信息"); 结果
double y1 = Convert.ToDouble(this.textBox2.Text);
double x2 = Convert.ToDouble(this.textBox3.Text);
double y2 = Convert.ToDouble(this.textBox4.Text);
double x3 = Convert.ToDouble(this.textBox5.Text);
double y3 = Convert.ToDouble(this.textBox6.Text); double a = System.Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
double b = System.Math.Sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
double c = System.Math.Sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)); double L = a + b + c;
double p = L / 2;
double S = System.Math.Sqrt(p*(p - a)*(p - b)*(p - c)); MessageBox.Show("三角形周长:" + L.ToString() + Environment.NewLine + "三角形面积:" + S.ToString(), "提示信息"); 结果
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询