| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10992 | Matrix class |
|
| 10993 | Polynomial class |
|
| 10997 | Queue |
|
Description
Create a class Matrix to represent a N * N matrix.
Provide public member functions that perform or derive:
- Matrix addition.
- Matrix subtraction.
- Matrix Multiplication.
- Adding cell value by 1 (module 10). That is, if after adding 1, a cell value becomes 10 we change it to 0.
- Matrix Transpose.
Hint:
Transpose of a Matrix:
A matrix which is formed by turning all the rows of a given matrix into column and vice-versa.
Example:

Note:
1. This problem involves three files.
- function.h: Class definition of Matrix.
- function.cpp: Member-function definitions of Matrix.
- main.cpp: A driver program to test your class implementation.
You will be provided with function.h and main.cpp, and asked to implement function.cpp.
function.h
main.cpp
2. For OJ submission:
Step 1. Include function.h into function.cpp and then implement your function.cpp. (You don’t need to modify function.h and main.cpp)
Step 2. Submit the code of function.cpp into submission block.
Step 3. Check the results and debug your program if necessary.
Input
The first line has an integer N (1<=N<=50), which means the size of the matrix. The total number of elements in the matrix is thus N * N.
For the next 2N lines: the first N lines specify the elements of the first matrix a, and the following N lines specify those of the second matrix b. All of the integers in the same line are separated by a space.
Output
Your program should print the corresponding results followed by a new line character.
Sample Input Download
Sample Output Download
Partial Judge Code
10992.cppPartial Judge Header
10992.hTags
Discuss
Description
Create a class Polynomial. The internal representation of a Polynomial is an array of terms. Each term contains a coefficient and an exponent, e.g., the term 2x4 has the coefficient 2 and the exponent 4.
- Use a 51-element array, coefficients, of digits to store each coefficient.
- Use a integer variable, greatestPower, to store an exponent.
Provide public member functions that perform each of the following tasks:
- Adding two Polynomial.
- Subtracting two Polynomial.
- Multiplying two Polynomial.
- Printing coefficients of the Polynomial in descending order.
Note:
1. This problem involves three files.
- function.h: Class definition of Polynomial.
- function.cpp: Member-function definitions of Polynomial.
- main.cpp: A driver program to test your class implementation.
You will be provided with main.cpp, and asked to implement function.h and function.cpp.
function.h
main.cpp
2. For OJ submission:
Step 1. Submit only your function.cpp into the submission block.
(***Note that you don’t need to submit your function.h.)
Step 2. Check the results and debug your program if necessary.
Input
There are four lines.
The first two lines represent the greatest power and the corresponding coefficients of the first polynomial.
The last two lines represent the greatest power and the corresponding coefficients of the second polynomial.
Note that the coefficients are in descending order and each element is separated by a blank.
Output
Your program should print the coefficients of the sum, difference and product of these two polynomials in descending order, respectively.
Note that every answer should be followed by a new line character.
Sample Input Download
Sample Output Download
Partial Judge Code
10993.cppPartial Judge Header
10993.hTags
Discuss
Description
A queue is an abstract data type that serves as a collection of elements, where nodes are removed only from the head of the queue and are inserted only at the tail of the queue. Two principal operations can be used to manipulate a queue: enqueue, which inserts an element at the tail, and dequeue, which removes the element at the head of the collection.

Let’s see how the queue data structure can be realized in C++.We have an approach to implement queue: linked list. Thus, we define a class as follows:
class List_queue {
public:
List_queue();
~List_queue();
void enqueue(const int &);
void dequeue();
void print();
private:
ListNode *head;
ListNode *tail;
};
where List_queue implements the queue data structure.
REQUIREMENTS:
Implement the constructor, destructor, enqueue(), dequeue() and print() member functions of the List_queue class.
Note:
1.This problem involves three files.
- function.h: Class definitions.
- function.cpp: Member-function definitions.
- main.cpp: A driver program to test your class implementation.
You will be provided with main.cpp and function.h, and asked to implement function.cpp.
function.h
main.cpp
2.For OJ submission:
Step 1. Submit only your function.cpp into the submission block.
Step 2. Check the results and debug your program if necessary.
Input
There are three kinds of commands:
- “enqueue integerA” represents inserting an element with int value A at the tail of the queue.
- “dequeue” represents removing the element at the head of the queue.
- “print” represents showing the current content of the queue.
Each command is followed by a new line character.
Input terminated by EOF.
Output
The output should consist of the current state of the queue.
When the queue is empty, you don’t need to print anything except a new line character.