怎么用VS2005编写完成三角形三边关系的编程

来源:百度知道 编辑:UC知道 时间:2024/06/15 12:58:44
(1)(a,b,c为三角形三条边长
1=<a<=100;1=<b<=100;1=<c<=100
a+b1)输入条件限定:
>c;b+c>a;c+a>b
(2)输出情况:
 如果不满足输入的6个条建中的任一条:输出“输入违法!”
注:输入违法包括三角形的边为非整数、负数、为零,或者边数少于三条,两边之和小于第三边等等
 如果是三边相等,输出“等边三角形”
 如果有两边相等,输出“等腰三角形”
 如果是三边都不相等,输出“一般三角形”
用任意一种编程语言来完成问题也可 如,C ,VB.net, JAVA, C#

C#写了段代码,不知道有没有问题。

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
while (true)
{
int a = 0;
int b = 0;
int c = 0;
String s = null;
Console.Out.WriteLine("\n请输入数值:");

Console.Out.Write("a=");
s = Console.ReadLine();
if (!int.TryParse(s, out a))
{
Console.Out.WriteLine("输入违法!");
continue;
}

Console.Out.Write("b=");
s = Console.ReadLine();
if (!int.TryParse(s, out b))
{