1 条题解
-
0
C++ :
#include <iostream> using namespace std; class Rectangle { public: Rectangle(double l, double w); Rectangle() {} double CalArea(); protected: double length; double width; }; class Rectangular:public Rectangle { public: Rectangular(double l, double w, double h); double CalVolume(); private: double height; }; Rectangle::Rectangle(double l, double w) { length = l; width = w; } Rectangular::Rectangular(double l, double w, double h):Rectangle(l,w),height(h) {} double Rectangle::CalArea() { return length*width; } double Rectangular::CalVolume() { return height*width*length; } int main() { double l,w,h; cin>>l>>w; Rectangle rectangle(l,w); cout<<rectangle.CalArea()<<endl; cin>>l>>w>>h; Rectangular rectangular(l, w, h); cout<<rectangular.CalVolume()<<endl; return 0; }
- 1
信息
- ID
- 1382
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者