1 条题解
-
0
C++ :
#include<iostream> #include<string.h> using namespace std; class circle { protected: float r; public: circle(float r0=0) { r=r0;} double getarea( ) {return 3.14*r*r;} }; class table { protected: float high; public: table(float high1=0) {high=high1;} float getheight( ) {return high;} }; class roundtable:public circle,public table { private: string color; public: roundtable(string color1,float high,float r) :table(high),circle(r) { color=color1; } string getcolor( ) {return color;} }; void display( roundtable &s) { cout.precision(2); cout.setf(ios::fixed); cout<<"圆桌的面积:"<<s.getarea()<<","; cout<<"高度:"<<s.getheight()<<","; cout<<"颜色:"<<s.getcolor()<<"。"<<endl; } int main() { float r,h; char color[10]; while( cin>>r>>h>>color) {roundtable rt(color,h,r); display(rt);} return 0; }
- 1
信息
- ID
- 1383
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者