LintCode之矩阵面积
2017-08-02 15:11
267 查看
实现一个矩阵类Rectangle,包含如下的一些成员变量与函数:
两个共有的成员变量 width 和 height 分别代表宽度和高度。
一个构造函数,接受2个参数 width 和 height 来设定矩阵的宽度和高度。
一个成员函数 getArea,返回这个矩阵的面积。
两个共有的成员变量 width 和 height 分别代表宽度和高度。
一个构造函数,接受2个参数 width 和 height 来设定矩阵的宽度和高度。
一个成员函数 getArea,返回这个矩阵的面积。
// 重点在于对构造方法的理解 public int width = 0, height = 0; public Rectangle(int wid, int hig) { width = wid; height = hig; } public int getArea() { return (width * height); } public static void main(String[] args) { Rectangle rec = new Rectangle(3, 4); rec.getArea(); // should get 12 }
相关文章推荐
- 一、lintcode刷题记录--矩阵面积、二叉树的最大节点、整数排序、删除链表中的元素
- 【LintCode】454.矩阵面积(入门)解题报告
- 【LintCode-454】矩阵面积(Java实现)
- LintCode_Java旅程 矩阵面积
- 【LintCode 入门】454. 矩阵面积
- (lintcode)第454题 矩阵面积
- 求全是1的最大矩阵面积 Maximal Rectangle @LeetCode
- lintcode-矩阵归零-162
- 九度OJ 1497 面积最大的全1子矩阵 -- 动态规划
- LintCode:搜索二维矩阵 II
- HDU 1505 City Game【矩阵的最大面积】
- Arithmetic problem | 找二维矩阵权值为1的最大矩形面积
- 矩阵归零-LintCode
- 面积最大的全1子矩阵--九度OJ 1497
- 最大子矩阵面积
- 面积最大的全1子矩阵
- [LintCode] Submatrix Sum 子矩阵之和
- lintcode[122]:直方图内最大矩形面积
- 面积最大的全1子矩阵
- 一个N*M的矩阵,找出这个矩阵中所有元素的和不小于K的面积最小的子矩阵