题解 | 设计立方体类

#include <iostream>
#include <pthread.h>
using namespace std;

class Cube {
private:
    int length;
    int width;
    int height;
public:
    Cube ()
    {
        cin>>length;
        cin>>width;
        cin>>height;
    }
    void print()
    {
        int S=(length *width+length*height+width*height)*2;
        int V=height*width*length;
        cout<<length<<" "<<width<<" "<<height<<" "<<S<<" "<<V<<endl;
    }
};


int main()
{
    Cube obj;
    obj.print();
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务