# include
# include
使用名称空间性病;
双三角形(双,双b,双c)//定义求三角形面积的函数
{
双s=(a + b + c)/2,
如果(a + b & lt;=c | | + c & lt; b=| | b + c & lt;=a)
{
扔;//不符合三角形条件抛出异常信息一个
}
返回sqrt (s * (s - a) * (s - b) * (s - c));}
int主要()
{
双三角形(双、双、双);
双a, b, c,
cin祝辞祝辞祝辞;比;b在祝辞c;
尝试//在试块中包括要检查的函数
{
,(比;0,,b在0,,c比;0)
{
cout & lt; & lt;三角形(a, b, c) & lt; & lt;endl;
cin祝辞祝辞祝辞;比;b在祝辞c;
}
}
抓住(双)//用捉捕捉异常信息并作相应处理
{
cout & lt; & lt;“=? lt; & lt;& lt; & lt;”,b=" & lt; & lt;b & lt; & lt;”,c=" & lt; & lt;c & lt; & lt;”,这并不是一个三角形!”& lt; & lt;endl;
}
cout & lt; & lt;“结束”& lt; & lt;endl;
系统(“暂停”);
返回0;
}
# include
使用名称空间性病;
空白f1 ()
{
空白f2 ();
尝试{
f2 ();}
抓住(char)
{
cout & lt; & lt;“ERROR1 !”;
}
cout & lt; & lt;“end1”& lt; & lt;endl;
}
空白f2 ()
{
空白f3 ();
尝试{
f3 ();}
抓住(int)
{
cout & lt; & lt;“ERROR2 !”& lt; & lt;endl;
}
cout & lt; & lt;“end2”& lt; & lt;endl;
}
空白f3 ()
{
双=0;
尝试{
扔;//抛出两类型异常
}
抓住(浮动)
{
cout & lt; & lt;“ERROR3 !”& lt; & lt;endl;
}
cout & lt; & lt;“end3”& lt; & lt;endl;
}
int主要()
{
空白f1 ();
尝试{
f1 ();}
抓住(double)
{
cout & lt; & lt;“ERROR0 !”& lt; & lt;endl;
}
cout & lt; & lt;“end0”& lt; & lt;endl;
系统(“暂停”);
返回0;
}