今天刷了lintcode-矩阵面积的题目,大概是练习构造函数,代码在VS上通过了,但是在lintcode运行,一直显示测试中。
总之,先把代码放在这里吧.
#include
using namespace std;
class Rectangle
{
public:
Rectangle(int,int);
int width,height;
int getArea();
};
Rectangle::Rectangle(int w,int h)
{
width=w;
height=h;
}
int Rectangle::getArea()
{
return(width*height);
}
void main()
{
int i,j;
cin>>i;
cin>>j;
Rectangle test(i,j);
cout<<"面积的大小为"<
<