| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10895 | Grade report(different order) |
|
| 11219 | Get your array and then sort it! |
|
| 11728 | Distance on 2D plane |
|
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
[Partial Judge]
Given a sequence of integers, sort it in increasing order by implementing the function my_sort().
The main code and the header code are provided as below.
There are two functions defined in the header file:
- int* readInput();
- void my_sort(int* B);
Function int* readInput() is given. It will read the input numbers, save it into an array, say Seq, and finally return the address of the array.
The first element of array Seq is the number of integers to be sorted. The following elements are the integers.
Function void my_sort(int* B) is the one leaved for you to implement. It take in a single argument B of type int*, whose value is the address of the address of the array Seq.
* Note that the address of the array Seq is returned by the function int* readInput().
* Also, you should be care of the actual type of the variable you want to access to. Do not be confused with the function definition.
* When submitting your code, remember to set Language option to "C: -O2 -lm -std=c99"
Input
A line of N integers seperated by a space in between.
100 <= N <= 1000.
The value of integer falls in the range of [-1000, 1000].
Input is handled by the provided function int* readInput(). You don't need to worry about it.
Output
A line of sorted integers seperated by a space in between. No extra space after the last integer. An newline character ('\n') is appended at the end.
You don't need to worry about it. It is handled in the provided main function.
Sample Input Download
Sample Output Download
Partial Judge Code
11219.cPartial Judge Header
11219.hTags
Discuss
Description
TA knows that in Monday lecture, HT taught everyone the concept of structure.
Moreover, the hackthon will be held on Saturday, and you students will use lots of APIs, containing many usages of structure.
Therefore, TA wants to ensure that you have enough basic knowledge of structure through this problem.
In this problem, TA forces you to use structure to record imformation and use afterward.
You will be given several points' locations on 2D plane(x, y), and you should compute the Euclidean distance of specific two points.

(Hint: you can use sqrt() to calculate the square root)

You should implement funcion.c below and submit it. (Due to Partial judge)
#include <stdio.h>
#include <math.h>
#include "function.h"
Point * ones_vec_1(int length)
{
/// Please implement
/// 1. Malloc memory for point array
/// 2. Read values into point array
/// 3. Return the address of the first element in the array
}
float compute_distance(Point* a, int first_id, int second_id)
{
float ans;
Point first_p, second_p;
/// Please implement
/// 1. Get two point from function argument
/// 2. Compute 2D distance and return ans
return ans;
}
You should see .c and .h file below to know how the function and the whole program works.
Input
Input may have several lines.
The first line contains an integer M, indicating how many points' locations you should read.
(Notice that the first point is indexed 0, and the second point is indexed 1, and so on...)
And the next M lines , each line has two integers, indicating point's location x and y.
The next line contains an integer N, indicating the number of the pairs of chosen two points.
And the next N lines, each line contains two integers, which are two indices representing two specific points needed to be calculated for Euclidean distance.
Output
Ouput has N lines.
Each line contains a floating number, indicating the Euclidan distance of two specific points.