矩形周长面积计算
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cstdlib>
using namespace std;
class Rectangle
{
private:
double Length;
double Width;
double Perimeter;
double area;
public:
void set_l(double length)
{
Length=length;
}
void set_w(double width)
{
Width=width;
}
double get_l()
{
return Length;
}
double get_w()
{
return Width;
}
void show()
{
Perimeter=(Length+Width)*2;
area=Length*Width;
cout << "请输入矩形周长:" << Perimeter <<endl;
cout << "请输入矩形面积:" << area <<endl;
}
};
int main()
{
Rectangle rec;
double length;
double width;
cout << "请输入矩形长度:" << endl;
cin >> length;
cout << "请输入矩形宽度:" << endl;
cin >> width ;
rec.set_l(length);
rec.set_w(width);
rec.show();
return 0;
}