c++:chang fang zhu de tiji yu mianji
2016-06-14 22:50
513 查看
#include<iostream>
#include<cmath>
using namespace std;
class Bulk
{
public:
void getbulk()
{
int l,w,h;
cout<<"请输入三个长方柱体的长宽高"<<endl;
cin>>l>>w>>h;
length=l;
width=w;
height=h;
}
void volume()
{
double v;
v=length*width*height;
cout<<"长方柱的体积为: "<<v<<endl;
}
void areas()
{
double s;
s=2*length*height+2*length*width+2*height*width;
cout<<"长方柱的总面积为: "<<s<<endl;
}
private:
double length,width,height;
};
int main()
{
Bulk a,b,c;
a.getbulk();
b.getbulk();
c.getbulk();
a.volume();
b.volume();
c.volume();
a.areas();
b.areas();
c.areas();
return 0;
}
#include<cmath>
using namespace std;
class Bulk
{
public:
void getbulk()
{
int l,w,h;
cout<<"请输入三个长方柱体的长宽高"<<endl;
cin>>l>>w>>h;
length=l;
width=w;
height=h;
}
void volume()
{
double v;
v=length*width*height;
cout<<"长方柱的体积为: "<<v<<endl;
}
void areas()
{
double s;
s=2*length*height+2*length*width+2*height*width;
cout<<"长方柱的总面积为: "<<s<<endl;
}
private:
double length,width,height;
};
int main()
{
Bulk a,b,c;
a.getbulk();
b.getbulk();
c.getbulk();
a.volume();
b.volume();
c.volume();
a.areas();
b.areas();
c.areas();
return 0;
}
相关文章推荐
- ios学习路线—C语言(枚举)
- 29. Divide Two Integers
- 头文件里面实现一个函数,在两个cpp中包含,则重复定义,如果加上inline则不会报错
- C语言输入函数区别
- [leetcode] 【字符串】 10. Regular Expression Matching
- C++继承二
- C语言学习笔记 链表基础
- 范型程序设计——洗牌
- 基本数据类型
- 【c++程序】计算字符个数
- 8大常用通讯中间件/MQ使用总结
- C++ 智能指针详解
- c++ 需要用拷贝构造函数的情况
- Effective C++--条款20:适当地用pass-by-reference-to-const代替pass-by-value
- 大牛C++编程开发学习建议50条
- C++中的Sleep() 函数
- C语言学习总结
- C++之多线程(C++11 thread.h文件实现多线程)
- 动态存储分配及深复制——人数不定的工资类
- [C++ 面试基础知识总结] 泛型算法