| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11438 | Implement a list 2 (back) |
|
| 11443 | 3DShape |
|
| 11461 | Copy a vector (Implement a vector 7) |
|
| 11462 | cppreference |
|
Description
You must follow the rules as below:
1. do not use any static variables
2. do not use any variables which is not inside a function
3. only new, operator new, delete and operator delete are allowed to allocate or deallocate memory
You are required to implement a list.
Input
The input consist of a number of operations. Each operations (erase, insert and S) are separated by a newline character ('\n').
Operation push_back: following by a non-negative integer (insert value, 0<=insert value<65535). Push a node at the end position with insert value.
Operation pop_back: Pop a node at the end position.
Operation show: print the value of all nodes in the list. Print a whitespace character (' ') after printing the value of nodes. If the list is empty, do not print anything.
Output
Implement List (constructor, destructor, push_back and pop_back) and operator<<(std::ostream &,const List &lst).
Sample Input Download
Sample Output Download
Partial Judge Code
11438.cppPartial Judge Header
11438.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
You must follow the rules as below:
1. do not use any static variables
2. do not use any variables which is not inside a function
3. only new, operator new, delete and operator delete are allowed to allocate or deallocate memory
4. memory usage limit: 16384 byte
You are required to implement a vector.
You have to enable C++11 in this problem. (e.g. "g++ -std=c++11 ...")
Input
There are seven functions in Vector that you have to implement, the functionality is as below:
- default constructor: initializes pointers. Do not allocate memory.
- copy constructor: copys the elements of rhs. The new capacity is rhs.size().
- copy assignment operator: copys the elements of rhs. The new capacity is max(capacity(), rhs.size()).
- erase: erases a element at pos.
- insert: inserts a val at pos. When capacity is not enough, the new capacity is max(old capacity + 1, old capacity * 3).
- reserve: reserves storage (Increase the capacity of the container to a value that's equal to new capacity. If new capacity is greater than the current capacity, new storage is allocated, otherwise the method does nothing.).
- destructor
Output
Complete a Vector (default constructor, copy constructor, copy assignment operator, erase, insert, reserve and destructor).