您的位置:首页 > 其它

输入三条边判断三角形

2014-11-01 17:43 246 查看
软件技术1班

作    者:A29 邢晓康

完成日期:2014年 10 月 25 日

问题描述:根据输入的三条边判断三角形

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 三角形
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入第一条边");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第二条边");
int b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第三条边");
int c = Convert.ToInt32(Console.ReadLine());
Triangle t = new Triangle();
t.Func(a, b, c);
}
}

class Triangle
{
public void Func(int b1, int b2, int b3)
{
if (b1 + b2 > b3 && b1 + b3 > b2 && b2 + b3 > b1)
{
Console.WriteLine("可以组成三角形");
if (b1 == b2 && b2 == b3)
Console.WriteLine("是等边三角形");
else
if (b1 == b2 || b2 == b3 || b1 == b3)
Console.WriteLine("是等腰三角形");
}
else
Console.WriteLine("输入的三边不能组成三角形");
Console.Read();
}
}
}









总结:通过这次练习,我略略地了解了如何通过C#语言中的IF语句编写此类程序,感觉受益颇深。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐