| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11420 | Implement a vector 1 |
|
| 11415 | Word Scramble |
|
Description
Warning: You are not allowed to use:
1. any static variables
2. any variables which is not inside a function
3. malloc and free
The storage of the vector is handled automatically, being expanded and contracted as needed. Vectors usually occupy more space than static arrays, because more memory is allocated to handle future growth. This way a vector does not need to reallocate each time an element is inserted, but only when the additional memory is exhausted.
REQUIREMENTS:
Implement the push_back(), pop_back(), reserve() and destructor member functions of Vector classes.
Note:
If the value of size is equal to the value of capacity, and you need to change the value of capacity (reallocate memory) when you push_back a new element. The rule of increasing capacity is: new capacity = max(old capacity + 1, old capacity * 3).
The constructor of vector will not create an array (which means size and capacity is 0).
Input
here are five kinds of commands:
- pop_back: removes the last element
- push_back: adds an element to the end
- capacity: returns the number of elements that can be held in currently allocated storage
- size: returns the number of elements
- 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.)
Each commands is followed by a new line character ('\n').
Output
The output should consist of the current state of the vector.
Sample Input Download
Sample Output Download
Partial Judge Code
11420.cppPartial Judge Header
11420.hTags
Discuss
Description
Write a program that will reverse the letters in each of a sequence of words while preserving the order of the words themselves.
Input
The input file will consist of several lines of several words. Words are contiguous stretches of printable characters delimited by white space.
Output
The output will consist of the same lines and words as the input file. However, the letters within each word must be reversed.
If the input is "I love you.", the output should be "I evol .uoy"