输入三条边判断三角形
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语句编写此类程序,感觉受益颇深。
相关文章推荐
- C语言-根据输入的三角形的三条边判断三角形的类型,并输出它的面积和类型
- C# 输入三条边,判断是否组成三角形
- 输入三条边,判断三角形
- 控制台输入三条边长,判断是否能构成三角形。如果能构成,输出三角形的周长,并且告知该三角形是什么类型(锐角、直角、钝角),再判断下该三角形是 等腰、等边还是不等边三角形。
- 输入三条边,判断是否可构成三角形
- 判断输入三条边能否构成三角形
- 输入三条边并判断是不是三角形,算出面积
- 输入三条边并判断是否为三角形,若能构成三角形,指出其为何种三角形:等边、直角亦或者一般三角形
- python:任意输入3个数,判断能否组成三角形
- 任意输入三个数判断其是否为三角形
- c语言:任给三条边长,判断能否构成三角形,如果能,求出其面积和周长
- 从键盘任意输入三角形的三边长为a,b,c,编程判断a,b,c的值能否构成一个三角形,若能,请算出面积·若不能就输出不能构成三角形。
- 判断输入的三个数据是否可以构成一个三角形
- 输入三个数, 判断是什么样的三角形
- 4.3 输入三角形三条边,判断三角形类别
- java-第十三章-类的无参方法(一)-根据三角形的三条边长,判断是直角,锐角还是钝角三角形
- 一个窗口,用户输入三个数,你判断能否构成三角形以及面积
- P122.10(编写一个程序,要求输入三角形的三条边...)
- 如何判断三条线段组成什么三角形
- 《C++第六周实验报告4-1》---设计一个三角形类,能够输入三角形的三个顶点,求出其面积、周长,并判断其是否为直角三角形和等腰三角形。