| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10895 | Grade report(different order) |
|
| 10945 | Increasing linked list |
|
Description
Given a grade report for all students in a class, which includes student ID, Chinese grade, English grade, math grade, and science grade for each student. Please list the report sorted in two different way.
If the order is descending, sort the grade by the total grade from high to low. If the total grade is the same between two students, then sort by order of Chinese grade, English grade, math grade, science grade, and student ID, which is from high to low for all grades and from low to high for student ID.
If the order is ascending, sort the grade by the total grade from low to high. If the total grade is the same between two students, then sort by order of Chinese grade, English grade, math grade, science grade, and student ID, which is from low to high for all grades and from low to high for student ID.
Note that in both two way, the student ID is sorted from low to high.
You need to store these information in structures:
typedef struct
{
int ID;
int Chinese, English, math, science;
int total;
} Grade;
HINT
Hint: While sorting, you can use qsort in <stdlib.h> or write other sorting algorithms by your self.
function.h
main.c
Input
The first line contains an integer N and a string, which means the number of students in the class and the order which grade are sorting in respectively.
In the following N lines, there are 5 integers: student ID, Chinese grade, English grade, math grade, and science grade in each line in order, which are separate by spaces.
Output
List the sorted report, while each line contains student ID, total grade, Chinese grade, English grade, math grade, and science grade in order, where there is a '\t' between each number. Note that there is a '\n' at the end of each line.
Sample Input Download
Sample Output Download
Partial Judge Code
10895.cPartial Judge Header
10895.hTags
Discuss
Description
Given a link list structure named Node.
typedef struct _Node {
int data;
struct _Node *next;
} Node;
Use this structure to implement a increasing integer link list.
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
A non negative integer data per rows, if input is smaller then 0 then exit the while loop and exit the program.
Output
Please follow the output of program