-->
当前位置:首页 > 题库

PROGRAMMING:Edit triangle

Luz5年前 (2021-05-10)题库450
There is a triangle on the two-dimensional plane, which can be edited by command. The command translate DX, Dy is to translate the triangle (DX, Dy); The command rotate angle is to rotate the triangle around its center (the average position of three vertices); The command scale ratio is to scale the triangle relative to its center position (for example, 1.0 means no scaling, 2.0 means doubling, 0.5 means doubling); The command Undo is to undo an editing operation.
###Input format:
The first line gives six real numbers x0, Y0, x1, Y1, X2, Y2, which represent the coordinates of the three vertices of the triangle. The second line gives a positive integer n (1 = < n < = 100), indicating the number of commands, and then the N line gives specific editing commands.
###Output format:
Output the three vertex coordinates of the edited triangle. Each number is divided by a space. Do not add more space after the last number. All real numbers have 3 decimal places.
###Example:
For example, enter 1:
```in
3.0 3.0 4.0 3.0 3.0 4.0
one
translate 1.5 -1.5
```
Output:
```out
4.500 1.500 5.500 1.500 4.500 2.500
```
For example, enter 2:
```in
3.0 3.0 4.0 3.0 3.0 4.0
one
rotate 90.0
```
Output:
```out
3.667 3.000 3.667 4.000 2.667 3.000
```
For example, enter 3:
```in
3.0 3.0 4.0 3.0 3.0 4.0
one
scale 0.5
```
Output:
```out
3.167 3.167 3.667 3.167 3.167 3.667
```
For example, enter 4:
```in
3.0 3.0 4.0 3.0 3.0 4.0
four
scale 0.5
undo
rotate 90.0
translate 0.5 0.6
```
Output:
```out
4.167 3.600 4.167 4.600 3.167 3.600
```






answer:If there is no answer, please comment