设为首页 加入收藏

TOP

C++_构造函数与析构函数(六)
2019-03-13 00:08:03 】 浏览:418
Tags:构造 函数
eturn 2 * PI * radius; } // 计算圆的面积 float Circle::Area() const { return PI * radius * radius; } void main () { float radius; float FenceCost, ConcreteCost; // 提示用户输入半径 cout<<"Enter the radius of the pool: "; cin>>radius; // 声明 Circle 对象 Circle Pool(radius); Circle PoolRim(radius + 3); //计算栅栏造价并输出 FenceCost=PoolRim.Circumference()*FencePrice; cout<<"Fencing Cost is ¥"<<FenceCost<<endl; //计算过道造价并输出 ConcreteCost=(PoolRim.Area()- Pool.Area())*ConcretePrice; cout<<"Concrete Cost is ¥"<<ConcreteCost<<endl; }

运行结果

Enter the radius of the pool: 10
Fencing Cost is ¥2858.85
Concrete Cost is ¥4335.39
首页 上一页 3 4 5 6 下一页 尾页 6/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇POJ3734 Blocks(生成函数) 下一篇C++_类和对象

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目