一个简单的C#程序...有不清楚的地方。。望指教

来源:百度知道 编辑:UC知道 时间:2024/06/25 02:52:23
using System;
using System.Collections.Generic;
using System.Text;
namespace triangle
{
class Program
{
static void Main(string[] args)
{
double a, b, c, d;
double g;
a = double.Parse(Console.ReadLine());
b = double.Parse(Console.ReadLine());
c = double.Parse(Console.ReadLine());
if (a + b > c&&a + c > b&&b + c > a)
{
Console.WriteLine("能够拼成一个三角形!");
}
else
{ Console.WriteLine("error!无法拼成三角形!"); Console.ReadLine(); return; }
if (a + b == c * 2&&a==b)
{ Console.WriteLine("三角形是等边三角形!"); goto x; }
if (a == b | b == c | a == c & a+b != c*2)
Console.WriteLine("三角形是等腰三角形!");

x: if (a >= b && a &g

逻辑或运算符是||,你掉了个 |
我没有看程序,不知道是不是这个原因 你试试!

if (a == b | b == c | a == c & a+b != c*2)
Console.WriteLine("三角形是等腰三角形!");

a == b || b == c || a == c 逻辑运算符号应该是"||"吧!

还有,楼主为什么不用else if呢? 那么多的情况

if()
{}
else if()
{}
else if()
{}
else
{}

if (b >= c && b >= a) { g = a; a = b; b = g; }
if (c >= a && c >= b) { g = a; a = c; c = g; }
//这两句为赋值,

double e = Math.Acos(d); //这句的余弦函数不对吧~