Circle and Rectangle

    来源:这个图形是一道小学五年级几何习题的答案。

 

 

% Circle and Rectangle
% Author: Bentley 
\documentclass{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>

\begin{comment}
:Title: Circle and Rectangle

\end{comment}
\begin{document}
\pagestyle{empty}

 \begin{figure}[bt]
 \centering
 \scalebox{4}
 {
 \begin{tikzpicture}[scale=6]
	\tikzstyle{vertex}=[rectangle,minimum size=10pt,inner sep=1pt, green]
	\tikzstyle{edge} = [draw,thick,-,black]
	\node[vertex] (v0) at (0,0) {$A$};
     	\node[vertex] (v1) at (0,1) {$B$};
 	\node[vertex] (v2) at (1,0) {$C$};
   	\node[vertex] (v3) at (1,1) {$D$};
	\node[vertex] (v4) at (0,0.5) {$E$};
  	\draw[edge]   (v0)--(v1) --(v3)--(v2)--(v0);
	%\draw[semithick] (0,0) arc (0:180:1);
	\node [draw, thick, minimum size=12cm, circle,blue] at (0,0) {};
	\node [draw, thick, minimum size=12cm, circle,blue] at (0,1) {};
	\node [draw, thick, minimum size=6cm, circle,blue] at (0,0.5) {};
	\node [draw, thick, minimum size=6cm, circle,blue] at (1,0.5) {};
	\draw(0,0.5)--(1,0.5);
	%\draw(0.5,0.5)--(0.5,0);
    	\draw(0,1)--(1,0.5);
     

 \end{tikzpicture}
 }
 \caption{Circle and Rectangle}
 \end{figure}
\end{document}
 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure, I can help you with that! Here is the implementation of the Shape class and its subclasses Circle and Rectangle, along with the global function showShape() and the main() function: ``` #include <iostream> #include <string> using namespace std; class Shape { protected: string name; string color; public: Shape(string n, string c) : name(n), color(c) {} virtual void show() { cout << "Name: " << name << ", Color: " << color << endl; } }; class Circle : public Shape { private: int radius; public: Circle(string n, string c, int r) : Shape(n, c), radius(r) {} void show() { Shape::show(); cout << "Radius: " << radius << endl; } }; class Rectangle : public Shape { private: int width; int height; public: Rectangle(string n, string c, int w, int h) : Shape(n, c), width(w), height(h) {} void show() { Shape::show(); cout << "Width: " << width << ", Height: " << height << endl; } }; void showShape(const Shape &shape) { shape.show(); } int main() { Circle circle1("Circle 1", "Red", 5); Rectangle rectangle1("Rectangle 1", "Blue", 10, 8); Shape *p_shape = &circle1; showShape(*p_shape); p_shape = &rectangle1; showShape(*p_shape); return 0; } ``` In this implementation, we have defined the Shape class as a base class with two data members: name and color. We have also defined two subclasses, Circle and Rectangle, with additional data members radius and width/height respectively. Each class has a constructor to initialize its data members, and a show() function to display its data members. We have also defined a global function showShape() which takes a Shape object as its argument and calls its show() function to display its content. Finally, in the main() function, we create a Circle object circle1 and a Rectangle object rectangle1. We then define a Shape pointer p_shape to point to circle1, and call showShape(*p_shape) to display the circle's information. We then change p_shape to point to rectangle1, and call showShape(*p_shape) to display the rectangle's information.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值