首页 > 代码库 > Java基础 矩阵面积

Java基础 矩阵面积

 

提供 数据结构与算法题目 的平台是LintCode,参考链接是:http://www.lintcode.com/zh-cn/

 

问题描述:

技术分享

 

参考代码:

public class Rectangle {
    /*
     * Define two public attributes width and height of type int.
     */
    // write your code here
    public int width;
    public int height;

    /*
     * Define a constructor which expects two parameters width and height here.
     */
    // write your code here
    Rectangle(int width , int height){
        this.width = width;
        this.height = height;
    }
    
    /*
     * Define a public method `getArea` which can calculate the area of the
     * rectangle and return.
     */
    // write your code here
    public int getArea(){
        return this.width * this.height;
    }
}

 

结果与评价:

技术分享

 

Java基础 矩阵面积