python计算长方体体积最简单代码_求圆柱体积和长方体体积C++源代码

#include <iostream>

#define PI 3.1415926

using namespace std;

class Rectangle

{

protected:

float x, y, Length, Width;

public:

float Area()

{

return Length*Width;

}

Rectangle(float i, float j, float L, float W)

{

x = i;

y = j;

Length=L;

Width=W;

}

};

class Circle

{

protected:

float X, Y, R;

public:

float cc;

float Area()

{

return(R*R*PI);

}

Circle(float i, float j, float k)

{

X = i;

Y = j;

R = k;

}

};

class Cuboid :public Circle, public Rectangle

{

protected:

float High;

float VR, VC;

public:

Cuboid(float a, float b, float c, float d, float e, float f, float g, float h) :Rectangle( c, d, a, b), Circle( f, g, e)

{

High = h;

VR = Rectangle::Area()*High;

VC = Circle::Area()*High;

}

void show( void )

{

cout << "Length=" << Length << '\t' << "Width=" << Width << '\t' << "High=" << High << endl;

cout << "Rectangle Center coordinate = " << Rectangle::x << ',' << Rectangle::y << endl;

cout << "Cuboid Volume=" << VR << endl;

cout << "Radius=" << R << '\t' << "High=" << High << endl;

cout << "Circle Center coordinate = " << Circle::X << ',' << Circle::Y << endl;

cout << "Cylinder Volume=" << VC << endl;

cout<<"\narea = "<< Circle::Area()<<endl;

}

};

main()

{

Cuboid cub(10, 10, 10, 20, 30, 30, 10, 10);

cub.show();

}

你可能感兴趣的:(python计算长方体体积最简单代码_求圆柱体积和长方体体积C++源代码)