第十、十一周项目1 - 点-圆-圆柱类族的设计(3)
来源:互联网 发布:三生网络直销违法吗 编辑:程序博客网 时间:2024/05/18 04:27
#include<iostream>
#include<cmath>
using namespace std;
#define PI 3.1415926
class Point
{
public:
void setPoint(float i,float j);
float getX(){return x;}
float getY(){return y;}
float dr(Point &p1,Point &p2);
private:
float x;
float y;
};
void Point::setPoint(float i,float j)
{
x=i;
y=j;
}
float Point::dr(Point &p1,Point &p2)
{
float dr=0,dx=0,dy=0;
dx=p1.x-p2.x;
dy=p1.y-p2.y;
dr=sqrt(dx*dx+dy*dy);
return dr;
}
class Circle:public Point
{
public:
Circle(float x1,float y1,float x2,float y2){midpoint.setPoint(x1,y1);aroundpoint.setPoint(x2,y2);}
float setR();
void circle_area();
float getR(){return r;}
float getarea(){return area;}
float lcircle();
private:
float area;
float r;
Point midpoint;
Point aroundpoint;
};
float Circle::setR()
{
r=dr(midpoint,aroundpoint);
return r;
}
void Circle::circle_area()
{
r=setR();
area=PI*r*r;
cout<<"底面圆的面积为:"<<area<<endl;
}
float Circle::lcircle()
{
r=setR();
float l;
l=2*PI*r;
return l;
}
class Cylinder:public Circle
{
public:
Cylinder(float x1,float y1,float x2,float y2,float h1):Circle(x1,y1,x2,y2),h(h1){}
void cylinderarea();
void cylinder_volume();
private:
float h;
};
void Cylinder::cylinderarea()
{
float s;
s=2*getarea()+lcircle()*h;
cout<<"圆柱体的表面积为:"<<s<<endl;
}
void Cylinder::cylinder_volume()
{
float v;
v=getarea()*h;
cout<<"圆柱体的体积为:"<<v<<endl;
}
int main()
{
Cylinder cy1(0,0,3,4,1.0);
cy1.circle_area();
cy1.cylinderarea();
cy1.cylinder_volume();
return 0;
}
#include<cmath>
using namespace std;
#define PI 3.1415926
class Point
{
public:
void setPoint(float i,float j);
float getX(){return x;}
float getY(){return y;}
float dr(Point &p1,Point &p2);
private:
float x;
float y;
};
void Point::setPoint(float i,float j)
{
x=i;
y=j;
}
float Point::dr(Point &p1,Point &p2)
{
float dr=0,dx=0,dy=0;
dx=p1.x-p2.x;
dy=p1.y-p2.y;
dr=sqrt(dx*dx+dy*dy);
return dr;
}
class Circle:public Point
{
public:
Circle(float x1,float y1,float x2,float y2){midpoint.setPoint(x1,y1);aroundpoint.setPoint(x2,y2);}
float setR();
void circle_area();
float getR(){return r;}
float getarea(){return area;}
float lcircle();
private:
float area;
float r;
Point midpoint;
Point aroundpoint;
};
float Circle::setR()
{
r=dr(midpoint,aroundpoint);
return r;
}
void Circle::circle_area()
{
r=setR();
area=PI*r*r;
cout<<"底面圆的面积为:"<<area<<endl;
}
float Circle::lcircle()
{
r=setR();
float l;
l=2*PI*r;
return l;
}
class Cylinder:public Circle
{
public:
Cylinder(float x1,float y1,float x2,float y2,float h1):Circle(x1,y1,x2,y2),h(h1){}
void cylinderarea();
void cylinder_volume();
private:
float h;
};
void Cylinder::cylinderarea()
{
float s;
s=2*getarea()+lcircle()*h;
cout<<"圆柱体的表面积为:"<<s<<endl;
}
void Cylinder::cylinder_volume()
{
float v;
v=getarea()*h;
cout<<"圆柱体的体积为:"<<v<<endl;
}
int main()
{
Cylinder cy1(0,0,3,4,1.0);
cy1.circle_area();
cy1.cylinderarea();
cy1.cylinder_volume();
return 0;
}
0 0
- 第十、十一周项目1 - 点-圆-圆柱类族的设计(3)
- 第十、十一周项目1 - 点-圆-圆柱类族的设计(3)
- 第十、十一周项目1 - 点-圆-圆柱类族的设计(1)
- 第十、十一周项目1 - 点-圆-圆柱类族的设计(1)
- 第十、十一周项目一-点-圆-圆柱类族的设计(3)
- 第十/十一周项目一(3)-点-圆-圆柱类族的设计
- 第十、十一周项目一-点-圆-圆柱类族的设计(1)
- 第十、十一周项目1 - 点-圆-圆柱类族的设计(2)
- 第十/十一周项目一(1)-点-圆-圆柱类族的设计
- 第十、十一周项目1 - 点-圆-圆柱类族的设计(2)
- 第十、十一周项目2:点-圆-圆柱类族的设计(3)
- 第十、十一周项目2:点-圆-圆柱类族的设计(1)
- 第十、十一周项目一-点-圆-圆柱类族的设计(2)
- 第十/十一周项目一(2)-点-圆-圆柱类族的设计
- 第十一周项目1-点-圆-圆柱类族的设计(3)
- 第十一周上机实践项目1(3):点-圆-圆柱类族的设计
- 第十 十一周点-圆-圆柱类族的设计(3)
- 十一周项目-1-点-圆-圆柱类族的设计(3)
- STL之*min_element , *max_element ,*nth_element()[取容器中最大元素 最小元素 第n元素]
- git和TortoiseGit使用
- 第十一周项目二储存班长信息的学生类
- 快速排序
- ubuntu php imageMagick
- 第十、十一周项目1 - 点-圆-圆柱类族的设计(3)
- 直接插入排序
- 面试题九斐波那契和青蛙跳台阶
- Session 初步(二) 之 HTTP Session 浅析
- Apache Mina 入门实例
- 第十、十一周实践项目2 - 存储班长信息的学生类
- hihoCoder 1015 KMP算法
- 折半(二分)插入排序
- XML文件解析