(lintcode)第454题 矩阵面积
2017-08-23 10:54
274 查看
要求:
实现一个矩阵类
两个共有的成员变量
一个构造函数,接受2个参数 width 和 height 来设定矩阵的宽度和高度。
一个成员函数
代码如下:
实现一个矩阵类
Rectangle,包含如下的一些成员变量与函数:
两个共有的成员变量
width和
height分别代表宽度和高度。
一个构造函数,接受2个参数 width 和 height 来设定矩阵的宽度和高度。
一个成员函数
getArea,返回这个矩阵的面积。
代码如下:
public class Rectangle { /* * Define two public attributes width and height of type int. */ // write your code here /* * Define a constructor which expects two parameters width and height here. */ // write your code here /* * Define a public method `getArea` which can calculate the area of the * rectangle and return. */ // write your code here private int width; private int height; public Rectangle(int width,int height){ this.width=width; this.height=height; } public int getArea(){ return width*height; } }
相关文章推荐
- 【LintCode 入门】454. 矩阵面积
- LintCode之矩阵面积
- 一、lintcode刷题记录--矩阵面积、二叉树的最大节点、整数排序、删除链表中的元素
- 【LintCode】454.矩阵面积(入门)解题报告
- 【LintCode-454】矩阵面积(Java实现)
- LintCode_Java旅程 矩阵面积
- 【 HDU 1255】 覆盖的面积(矩阵面积交,线段树,扫描法)
- 求全是1的最大矩阵面积 Maximal Rectangle @LeetCode
- 2017ICPC南宁赛区网络赛 Overlapping Rectangles(重叠矩阵面积和=离散化模板)
- 九度OJ 1497 面积最大的全1子矩阵 -- 动态规划
- HDU 1505 City Game【矩阵的最大面积】
- 矩阵求三角形面积——计算机图形学中
- LeetCode: 221_Maximal Square | 二维0-1矩阵中计算包含1的最大正方形的面积 | Medium
- 题目1497:面积最大的全1子矩阵
- 面积最大的全1子矩阵
- LintCode【简单】28. 搜索二维矩阵 。代码及思路
- 面积最大的全1子矩阵
- 九度OJ 1102 最小面积子矩阵 (+最短连续子序列)
- 一个N*M的矩阵,找出这个矩阵中所有元素的和不小于K的面积最小的子矩阵
- 面积最大的全1子矩阵