...包括的数据成员有宽(width)和长(length),并实现如下功能函数;_百度...

发布网友 发布时间:2024-10-23 23:27

我来回答

2个回答

热心网友 时间:2024-10-31 15:33

代码如下:

class Recangle{

private:

int width;

int length;

public:

Recangle()

{width = 0; length = 0;};

Recangle(int w,int h)

{width = w; height = h;};

int circumference()

{return 2*(width+height)};

int Area()

{return width * height};

void changeRec(int w, int h)

{width = w; height = h;};

};

C++编程如下

#include <iostream.h>

#include <std.h>

#include <math.h>

int main()

{

int a1=5,a2=6;

int b1=4,b2=5;

int s1,s2;

s1=a1*a2;

s2=b1*b2;

printf("矩形1的面积为:%d;",s1);

printf("矩形2的面积为:%d;",s2);

if(s1>s2)

{

printf("s1>s2");

}

else

{

if(s1<s2)

{

printf("s1<s2");

}

else

{

printf("s1=s2");

}

}

热心网友 时间:2024-10-31 15:32

class Recangle{
private:
int width;
int length;
public:
Recangle()
{width = 0; length = 0;};
Recangle(int w,int h)
{width = w; height = h;};
int circumference()
{return 2*(width+height)};
int Area()
{return width * height};
void changeRec(int w, int h)
{width = w; height = h;};
};

热心网友 时间:2024-10-31 15:29

代码如下:

class Recangle{

private:

int width;

int length;

public:

Recangle()

{width = 0; length = 0;};

Recangle(int w,int h)

{width = w; height = h;};

int circumference()

{return 2*(width+height)};

int Area()

{return width * height};

void changeRec(int w, int h)

{width = w; height = h;};

};

C++编程如下

#include <iostream.h>

#include <std.h>

#include <math.h>

int main()

{

int a1=5,a2=6;

int b1=4,b2=5;

int s1,s2;

s1=a1*a2;

s2=b1*b2;

printf("矩形1的面积为:%d;",s1);

printf("矩形2的面积为:%d;",s2);

if(s1>s2)

{

printf("s1>s2");

}

else

{

if(s1<s2)

{

printf("s1<s2");

}

else

{

printf("s1=s2");

}

}

热心网友 时间:2024-10-31 15:30

class Recangle{
private:
int width;
int length;
public:
Recangle()
{width = 0; length = 0;};
Recangle(int w,int h)
{width = w; height = h;};
int circumference()
{return 2*(width+height)};
int Area()
{return width * height};
void changeRec(int w, int h)
{width = w; height = h;};
};
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com