1210 - CS I2P (II) 2017 Lee Mid 2 Scoreboard

Time

2017/05/12 13:20:00 2017/05/12 15:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11437 string exam
11438 Implement a list 2 (back)
11443 3DShape
11444 cheat sheet
11445 Copy a vector (Implement a vector 6)

11437 - string exam   

Description

Write a program that will reverse the order of words in each sequence of sentences while preserve the order of letters.

Input

The input file will consist of several lines of several words. Words are contiguous stretches of printable characters delimited by a white space.

Output

The output will consist of the same lines and words as the input file. However, the order of words will be reversed.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11437.cpp

Partial Judge Header

11437.h

Tags




Discuss




11438 - Implement a list 2 (back)   

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.cpp

Partial Judge Header

11438.h

Tags




Discuss




11443 - 3DShape   

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.cpp

Partial Judge Header

11443.h

Tags




Discuss




11444 - cheat sheet   

Description

Inheritance type

Public

Protected

Private

Public data/ functions in the base class

Public in the derived class

Protected in the derived class

Private in the derived class

Protected data/ functions in the base class

Protected in the derived class

Protected in the derived class

Private in the derived class

Private data/fun in the base class

Not accessible in the derived class

Not accessible in the derived class

Not accessible in the derived class

 

 

 

 

 

 

 

 

 

Input

Output

Sample Input  Download

Sample Output  Download

Tags




Discuss




11445 - Copy a vector (Implement a vector 6)   

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: 9216 byte

You are required to implement a vector.

If you don't know what is an operator new, you can check 11419 - Using your vector.

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 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).

Sample Input  Download

Sample Output  Download

Partial Judge Code

11445.cpp

Partial Judge Header

11445.h

Tags




Discuss