输入三条边判断三角形

软件技术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语句编写此类程序,感觉受益颇深。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值