#include
#include
#define PI 3.1415926
using namespace std;
class Cylinder
{
private:
float r,h;
public:
Cylinder(float,float);
float perimeter(); //底圓周長(zhǎng)?
float circleArea(); //底圓面積?
float volume(); //圓柱體體積?
float getH();
};
Cylinder::Cylinder(float num1,float num2)
{
r=num1;
h=num2;
}
float Cylinder::perimeter()
{
return 2*PI*r;
}
float Cylinder::circleArea()
{
return PI*pow(r,2);
}
float Cylinder::volume()
{
return circleArea()*h;
}
float Cylinder::getH()
{
return h;
}
//計(jì)算圓柱體表面積?
float cylinderArea(float r,float h)
{
Cylinder cy=Cylinder(r,h);
float perimeter=cy.perimeter(); //底圓周長(zhǎng)?
float circleArea=cy.circleArea(); //底圓面積
float output;
output=circleArea*2;
output+=perimeter*cy.getH();
return output;?
}
//計(jì)算圓柱體體積?
float volume(float r,float h)
{
Cylinder cy=Cylinder(r,h);
return cy.volume();
}
int main()
{
Cylinder cy=Cylinder(1,10);
cout<<"底圓周長(zhǎng):"< <<"\t圓柱體體積"< cout<<"================="< cout<<"cylinderArea(float r,float h):"< <<"\tvolume(float r,float h):"< } 你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧
分享題目:用c++計(jì)算圓柱體的體積,底圓的面積和周長(zhǎng)-創(chuàng)新互聯(lián)
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)公司、品牌網(wǎng)站設(shè)計(jì)、企業(yè)建站、App設(shè)計(jì)、軟件開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源:
創(chuàng)新互聯(lián)
分享路徑:http://www.rwnh.cn/article18/esjdp.html
猜你還喜歡下面的內(nèi)容