题解 | #利用指针遍历数组#

设计立方体类

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

#include using namespace std;

class Cube { public: void setLength(int length) { m_length=length; } void setWidth(int width) { m_width=width; } void setHeight(int height) { m_height=height; } int getLength() { return m_length; } int getWidth() { return m_width; } int getHeight() { return m_height; } int getArea() { return 2m_lengthm_width+2m_lengthm_height+2m_widthm_height; } int getVolume() { return m_widthm_lengthm_height; } // write your code here...... private: int m_length; int m_width; int m_height;

};

int main() {

int length, width, height;
cin >> length;
cin >> width;
cin >> height;

Cube c;
c.setLength(length);
c.setWidth(width);
c.setHeight(height);

cout << c.getLength() << " "
    << c.getWidth() << " "
    << c.getHeight() << " "
    << c.getArea() << " "
    << c.getVolume() << endl;

return 0;

}

全部评论

相关推荐

牛客765689665号:没有实习是硬伤,央国企看学历
点赞 评论 收藏
分享
02-10 12:23
已编辑
新余学院 C++
采集想要offer:专业技能那里要一条一条的列出来吧,感觉你项目很厉害了,但是如果你不写技术栈面试官对你项目不太懂的话都没办法问你八股😂C++都是基架岗,都是一群9✌🏻在卷,我觉得你要是有时间学个go把MySQL和redis写上去找个开发岗吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务