//判斷邊界,大于0小于200,出界返回false
if((triangle.lbordera>0&&triangle.lbordera<200)
&&(triangle.lborderb>0&&triangle.lborderb<200)
&&(triangle.lborderc>0&&triangle.lborderc<200))
{
//判斷兩邊之和大于第三邊
if((triangle.lbordera<(triangle.lborderb+triangle.lborderc))
&&(triangle.lborderb<(triangle.lbordera+triangle.lborderc))
&&(triangle.lborderc<(triangle.lbordera+triangle.lborderb)))
istrue = true;
}
return istrue;
}
/**
* 判斷三角形類型
* 等腰三角形返回字符串“等腰三角形”;
* 等邊三角形返回字符串“等邊三角形”;
* 其它三角形返回字符串“不等邊三角形”;
*/
public string istype(triangle triangle)
{
string strtype = "";
// 判斷是否是三角形
if(this.istriangle(triangle))
{
//判斷是否是等邊三角形 if(triangle.lbordera==triangle.lborderb&&triangle.lborderb==triangle.lborderc)
strtype = "等邊三角形";
//判斷是否是不等邊三角形
else if((triangle.lbordera!=triangle.lborderb)&&
(triangle.lborderb!=triangle.lborderc)&&
(triangle.lbordera!=triangle.lborderc))
strtype = "不等邊三角形";
else
strtype="等腰三角形";
}
return strtype;
}
}