| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10947 | delete linked list |
|
| 11298 | Smart Phone Ranking Report |
|
| 11299 | Lab6_hint |
|
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.
Sample Input Download
Sample Output Download
Partial Judge Code
10947.cPartial Judge Header
10947.hTags
Discuss
Description
[Partial Judge]
Given a ranking report for smart phones, which includes Name, Price, Score and Size for each phone.
Please print out the report sorted in descending or ascending order.
- If the order is descending, sort the list by Price in descending order
- If Price is the same between two phones, sort them by Score in descending order
- If Score is the same between two phones, sort them by Size in descending order
- If Size is the same between two phones, sort them by Name in alphabetical order
2. If the order is ascending, sort the list by Price in ascending order.
- If Price is the same between two phones, sort them by Score in ascending order
- If Score is the same between two phones, sort them by Size in ascending order
- If Size is the same between two phones, sort them by Name in alphabetical order
Your mission is to implement the function "sortPhone(...)" .
If you want to implement extra comapre function , please upload your code in this form:
#include "function.h"
void compare_fun1(.....){
}
void compare_fun2(.....){
}
void sortPhone(Phone *PhoneList, int n, char *order){
....................
}
Note that you have to choose "C" compiler .
Input
The first line contains an integer N and a string, which means the number of phones and the order which data are sorting in respectively.
Input has N lines.
Each line contains 1 string, 1 integer and 2 double,representing phone Name, Price, Score and Size , which are separate by spaces.
Output
List the sorted report, while each line contains phone Name, Price, Score and Size in order, where there is a empty space '\t' between each data.
Note that there is a '\n' at the end of each line.
Sample Input Download
Sample Output Download
Partial Judge Code
11298.cPartial Judge Header
11298.hTags
Discuss
Description
specification of qsort :
qsort ( A , N , sizeof(Obj) , compare_function);
1. A is an array containing items you want to sort.
2. N is an integer , indicating how many items you want to sort.
3. If A is an array containing integers , you should fill in "sizeof(int)" as 3rd argument.
If A is an array containing many "Product" , you should fill in "sizeof(Product)" as 3rd argument
※Product can be a struct defined by anybody.
4. If you define a struct called "Product".
typedef struct
{
int Price;
int Size;
} Product;
You should implement the compare_function like this:
int compare_function1(const void *a, const void *b){
Product *c,*d;
c = (???) a;
d = (???) b;
if(..............) return -1; // Higher priority
else if (.................) return 1; // Lower priority
}
5. You may use "strcmp(name1,name2)" :
If name1 have higher priority , the function will return -1.
If name1 == name2 , the function will return 0.
If name 2 have higher priority , the function will return 1.