题解 | #设计立方体类#

设计立方体类

https://www.nowcoder.com/practice/0f02d35dcd564f0a87865d604eccbe18

#include<iostream>

template<typename T>
class Cube
{
public:

    T getArea(T length, T width, T height)
    {
        std::cout << length << " " << width << " " << height << " " ;
        auto it =  2 * (length * width + length * height + width * height);
        return it;
    }

    T getVolume( T length, T width, T height)
    {
        //std::cout << length << " " << width << " " << height << " " << std::endl;
        auto it =  length * width * height;
        return it;
    }

};

int main(void)
{
    Cube<int> get;
    int a, b, c;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;

    std::cout << get.getArea(a, b, c) << " " << get.getVolume(a, b, c) << std::endl;

    return 0;
}
全部评论

相关推荐

牛客773130651号:巨佬,简历模板换成上下的,左右的很烦,hr看着不爽。。。科大随便乱杀,建议能保研就保研,不行也得考一下 ,985硕去干算法,比开发强多了。开发许多双非都能搞,学历优势用不上,算法有门槛
点赞 评论 收藏
分享
吴offer选手:HR:我KPI到手了就行,合不合适关我什么事
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务