| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11422 | Shape |
|
| 11443 | 3DShape |
|
| 11484 | Draw the Shapes |
|
Description
Warning: You are not allowed to use malloc and free
Following the lecture slide :
Giving a bass-class Shape and 3 derived class : Triangle, Rectangle, Circle
You need to calculate the area and the perimeter of each shape.
note : You need to do some basic check: if the given information cannot form a shape (e.g. height of the rectangle is negative number....etc), then the area and perimeter would be both 0)
Input
There are only 3 shapes in this problem :
- Triangle, following by its 3 edges. (e.g. Triangle 3 4 5)
- Rectangle, following by its width and height. (e.g. Rectangle 5 7)
- Circle, following by its radius and the value of pi. (e.g. Circle 2 3.14)
Output
Ouput the total area and perimeter of all the shapes.
Sample Input Download
Sample Output Download
Partial Judge Code
11422.cppPartial Judge Header
11422.hTags
Discuss
Description
Warning: You are not allowed to use malloc and free
Giving a bass-class Shape3D and 4 derived class : Sphere (球體), Cone (圓錐), Cuboid (長方體), Cube (立方體)
You need to calculate the volume of each shape.
PS:
V of Sphere: V = 4/3 π r3
V of Cone: V = 1/3 π r2 h

note : Remember to do some basic check, if the input is illegal (e.g. length < 0, pi < 0 .....) then the volume should be 0.
You don't need to consider the scenario like Cuboid -1 -2 3, volume would be 0 instead of 6.
Hint1: Be careful the type of volume is double. 4/3=1 (int), so it should be 4.0/3.0
Hint2: You only need to implement the constructors.
Hint3: Note that Cube inherited Cuboid not Shape3D.
Input
There are only 4 shapes in this problem :
- Sphere, following by its radius and pi. (e.g. Sphere 30 3.14)
- Cone, following by its radius of bottom plane, height and pi. (e.g. Cone 3 100 3.14)
- Cuboid, following by its length, width and height. (e.g. Cuboid 2 3 7)
- Cube, following by its length. (e.g. Cube 2)
Output
Ouput the total volume of all the shapes.
Sample Input Download
Sample Output Download
Partial Judge Code
11443.cppPartial Judge Header
11443.hTags
Discuss
Description
Giving basic information of some shapes, you need to draw them on the Cartesian coordinate system and calculate the total area.
PI has already defined in function.h.
Input
There are only 2 shapes in this problem :
1. R (Rectangle), followed by 4 points. Each point represent 1 vertex of the rectangle, with the format (x, y).
2. C (Circle), followed by 1 point represent the centre of the circle, and a number of its radius.
If the radius is negative, set it to 0.
e.g., the result of sample input would be like :

Output
Output the total area of all the shapes.