📄 circle.cpp
字号:
#include <iostream>
#include <iomanip>
using namespace std;
const double pi = 3.141592653589793;
/*main information*/
void info()
{
cout << "circle, globe, cylinder";
cout << "\n_______________________";
}
/*circle*/
class circle
{
public:
circle(float r = 5, float xx = 0, float yy = 0, float zz = 0, float h = 10);
void set(float, float, float, float, float);
void show_circle();
void show_globe();
void show_cylinder();
~circle();
private:
float radius;
float x;
float y;
float z;
float height;
};
/**/
circle::circle(float r, float xx, float yy, float zz, float h)
{
radius = r;
x = xx;
y = yy;
z = zz;
height = h;
}
/*set*/
void circle::set(float r = 5, float xx = 0, float yy = 0, float zz = 0, float h = 10)
{
radius = r;
x = xx;
y = yy;
z = zz;
height = h;
}
/*show circle*/
void circle::show_circle()
{
cout << "\ncircle";
cout << "\nradius : " << radius;
cout << "\nposition : (" << x << ", " << y << ")";
cout << "\nperimeter: " << 2 * pi * radius;
cout << "\narea : " << pi * radius * radius;
cout << "\n_______________________";
}
/*show globe*/
void circle::show_globe()
{
cout << "\nglobe";
cout << "\nradius : " << radius;
cout << "\nposition: (" << x << ", " << y << ", " << z << ")";
cout << "\narea : " << pi * pi * radius * radius;
cout << "\nvolume : " << pi * pi * radius * radius * radius / 3;
cout << "\n______________________";
}
/**/
void circle::show_cylinder()
{
cout << "\ncylinder";
cout << "\nradius : " << radius;
cout << "\nheight : " << height;
cout << "\nposition: (" << x << ", " << y << ", " << z << ")";
cout << "\narea : " << 2 * pi * radius * (radius + height);
cout << "\nvolume : " << pi * radius * radius * height;
cout << "\n______________________";
}
/*~circle*/
circle::~circle(){cout << "\n~";}
/*source code*/
void test()
{
circle xiao;
xiao.set(1,1,1,1,3.4);
xiao.show_circle();
}
/*information of source code owner*/
void end()
{
cout << "\n\n______________\n";
cout << "xiao zhiqiang\n";
cout << "inxk@163.com\n";
cout << "Sep,2006";
getchar();
}
/*the main code*/
void main()
{
info();
test();
end();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -