| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10875 | Array Sorting |
|
| 10947 | delete linked list |
|
Description
Given a two-dimensional array of size R x 5 (1 < R < 100).
We want to sort the two dimensional array according to each column.
For example:
|
5 |
1 |
3 |
11 |
25 |
|
45 |
82 |
97 |
73 |
63 |
|
13 |
47 |
34 |
26 |
14 |
After sorted
|
5 |
1 |
3 |
11 |
14 |
|
13 |
47 |
34 |
26 |
25 |
|
45 |
82 |
97 |
73 |
63 |
Note that
1. This problem involves three files.
- function.h: Function definition of sortArray.
- function.c: Function implementation of sortArray.
- main.c: A driver program to test your implementation.
You will be provided with main.c and function.h, and asked to implement function.c.
2. For OJ submission:
Step 1. Submit only your function.c into the submission block. (Please choose c compiler)
Step 2. Check the results and debug your program if necessary.
Hints:
function.h
main.c
Input
The first line has an integer N(1<=N<=5000), which means the number of test cases.
For each case, the first line has an integer R (1<R<100) represent the numbers of rows. The following R lines, each containing 5 integers, specify the elements of the two-dimensional array.
Output
Print out all elements of the sorted array row-by-row.
All of the integers in the same line are separated by a space and there is a '\n' at the end of each line. All of the arrays should be separated by a new line character (\n).
Sample Input Download
Sample Output Download
Partial Judge Code
10875.cPartial Judge Header
10875.hTags
Discuss
Description
This problem will give you a sequence of positive integers. Use this sequence to create a linked list to store those integers. Next, the problem will give you another sequence of positive integers, p0, p1,…pk-1. Delete the nodes in the position at p0, p1, …pk-1 of the linked list, where 1<=p0<p1<…pk-1<=N. If the node is not existing,do nothing. And show the final results.
For example, if the first sequence is 1, 2, 3, 4, 5, 6,7, a linked list is created as
If the second sequence is 1, 1, 4, do the follows.
After p1=1, the list becomes
because the first node is 1. After p2 = 1, the list becomes
because the first node is 2. After p3 = 4, the list becomes
because the fourth node is 6.
The framework of the program is provided.
- Create a linked list from the input (createList)
- while there are still some data pi
- read in pi
- delete node at pi (deleteNode)
- print the remaining list (printList)
- free the list (freeList)
You will be provided with main.c and function.h. main.c contains the implementation of function printList, and freeList, and function.h contains the definition of node and the interface of createList(&head) and deleteNode(&head, pi). You only need to implement createList(&head) and deleteNode(&head, pi) in function.c, in which head is the head of the linked list, and pi is the node at pi to be deleted.
You will be provided with main.c and function.h, and asked to implement function.c.
For OJ submission:
Step 1. Submit only your function.c into the submission block. (Please choose c compiler)
Step 2. Check the results and debug your program if necessary.
main.c
function.h
Input
The input contains 2 sequence of positive integers as the linklist and the order, except the last one, which is -1, indicating the end of the sequence.
Output
The output contains the sequence of resulting linklist.