编写函数double rect-area(double length,double width=0),编写函数double rect-area(double length,double width=0):当width=0时计算正方形面积,否则计算长方形面积

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/23 19:59:34
编写函数doublerect-area(doublelength,doublewidth=0),编写函数doublerect-area(doublelength,doublewidth=0):当wid

编写函数double rect-area(double length,double width=0),编写函数double rect-area(double length,double width=0):当width=0时计算正方形面积,否则计算长方形面积
编写函数double rect-area(double length,double width=0),
编写函数double rect-area(double length,double width=0):当width=0时计算正方形面积,否则计算长方形面积

编写函数double rect-area(double length,double width=0),编写函数double rect-area(double length,double width=0):当width=0时计算正方形面积,否则计算长方形面积
double rect_area(double length,double width=0){
if(width==0.0) width=length;
return length*width;
}