img

#include <string>
#include<iostream>
using namespace std;
#define PI 3.14159f
class Shape
{public:
	virtual void set() = 0;
	virtual float getarea() = 0;
};
class Circle :public Shape
{
private:
	float r;
public:
	void set()
	{
		cin >> r;
	}
	float getarea()
	{
		return PI * r * r;
	}
};
class Square :public Shape
{
private:
	float d;
public:
	void set()
	{
		cin >> d;
	}
	float getarea()
	{
		return d*d;
	}
};
class Rectangle :public Shape
{
private:
	float l,h;
public:
	void set()
	{
		cin >> l>>h;
	}
	float getarea()
	{
		return l * h;
	}
};
class Trapezoid :public Shape
{
private:
	float a,b,c;
public:
	void set()
	{
		cin >> a>>b>>c;
	}
	float getarea()
	{
		return ((a + b) * c) / 2;
	}
};
class Triangle :public Shape
{
private:
	float a,b;
public:
	void set()
	{
		cin >> a>>b;
	}
	float getarea()
	{
		return a*b/2;
	}
};
void get(Shape& s)
{
	s.set();
}
float getwork(Shape &s)
{
	return s.getarea();
}
int main()
{
	Circle c;
	Square s;
	Rectangle r;
	Trapezoid t;
	Triangle t1;
	get(c);
	get(s);
	get(r);
	get(t);
	get(t1);
	printf("%.3f\n", getwork(c) + getwork(s) + getwork(r) + getwork(t) + getwork(t1));
}
posted on 2023-05-26 12:09  许七安gyg  阅读(6)  评论(0编辑  收藏  举报
$(document).ready(function() { // 禁止右键 $(document).bind("contextmenu", function(){return false;}); // 禁止选择 $(document).bind("selectstart", function(){return false;}); // 禁止Ctrl+C 和Ctrl+A $(document).keydown(function(event) { if ((event.ctrlKey&&event.which==67) || (event.ctrlKey&&event.which==86)) { //alert("对不起,版权所有,禁止复制"); return false; } }); });